home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / domacnost a kancelar / autoit / autoit-v3-setup.exe / Include / GuiListView.au3 < prev    next >
Encoding:
Text File  |  2007-09-08  |  88.5 KB  |  1,948 lines

  1. #include-once
  2.  
  3. #include <ListViewConstants.au3>
  4. #include <Array.au3>
  5. #include <Misc.au3>
  6. #include <Memory.au3>
  7.  
  8. ; ------------------------------------------------------------------------------
  9. ;
  10. ; AutoIt Version: 3.2.3++
  11. ; Language:       English
  12. ; Description:    Functions that assist with ListView.
  13. ;
  14. ; ------------------------------------------------------------------------------
  15.  
  16. ; ------------------------------------------------------------------------------
  17. ; These functions use some code developed by Paul Campbell (PaulIA) for the Auto3Lib project
  18. ; particularly the _Mem* function calls which can be found in Memory.au3
  19. ; ------------------------------------------------------------------------------
  20.  
  21. ; ------------------------------------------------------------------------------
  22. ; ------------------------------------------------------------------------------
  23. ; ------------------------------------------------------------------------------
  24. ; These Will need to be added to the ListViewConstants.au3 when we are finished
  25. ; From A3LConstants.au3
  26. Global Const $LVITEM = "int;int;int;int;int;ptr;int;int;int;int"
  27. ; converted from constants to Enum
  28. Global Enum $LVI_MASK = 1, $LVI_IITEM, $LVI_ISUBITEM, $LVI_STATE, $LVI_STATEMASK, $LVI_PSZTEXT, _
  29.         $LVI_CCHTEXTMAX, $LVI_IIMAGE, $LVI_LPARAM, $LVI_IINDENT
  30.  
  31. ;~ Global Const $LVCOLUMN                          = "int;int;int;ptr;int;int;int;int"
  32. Global $LVCOLUMN = "uint;int;int;ptr;int;int;int;int"
  33. ; converted from constants to Enum
  34. Global Enum $LVC_MASK = 1, $LVC_FMT, $LVC_CX, $LVC_PSZTEXT, $LVC_CCHTEXTMAX, $LVC_ISUBITEM, $LVC_IIMAGE, $LVC_IORDER
  35.  
  36. ; What I was using
  37. ;~ Global Const $LVITEM                            = "int;int;int;int;int;ptr;int;int;int;int;int;ptr"
  38. ; ------------------------------------------------------------------------------
  39. ; ------------------------------------------------------------------------------
  40. ; ------------------------------------------------------------------------------
  41.  
  42.  
  43. ; function list
  44. ;===============================================================================
  45. ; _GUICtrlListViewCopyItems
  46. ; _GUICtrlListViewDeleteAllItems
  47. ; _GUICtrlListViewDeleteColumn
  48. ; _GUICtrlListViewDeleteItem
  49. ; _GUICtrlListViewDeleteItemsSelected
  50. ; _GUICtrlListViewEnsureVisible
  51. ; _GUICtrlListViewGetBackColor
  52. ; _GUICtrlListViewGetCallBackMask
  53. ; _GUICtrlListViewGetCheckedState
  54. ; _GUICtrlListViewGetColumnOrder
  55. ; _GUICtrlListViewGetColumnWidth
  56. ; _GUICtrlListViewGetCounterPage
  57. ; _GUICtrlListViewGetCurSel
  58. ; _GUICtrlListViewGetExtendedListViewStyle
  59. ; _GUICtrlListViewGetHeader
  60. ; _GUICtrlListViewGetHotCursor
  61. ; _GUICtrlListViewGetHotItem
  62. ; _GUICtrlListViewGetHoverTime
  63. ; _GUICtrlListViewGetItemCount
  64. ; _GUICtrlListViewGetItemText
  65. ; _GUICtrlListViewGetItemTextArray
  66. ; _GUICtrlListViewGetNextItem
  67. ; _GUICtrlListViewGetSelectedCount
  68. ; _GUICtrlListViewGetSelectedIndices
  69. ; _GUICtrlListViewGetSubItemsCount
  70. ; _GUICtrlListViewGetTopIndex
  71. ; _GUICtrlListViewGetUnicodeFormat
  72. ; _GUICtrlListViewHideColumn
  73. ; _GUICtrlListViewInsertColumn
  74. ; _GUICtrlListViewInsertItem
  75. ; _GUICtrlListViewJustifyColumn
  76. ; _GUICtrlListViewScroll
  77. ; _GUICtrlListViewSetCheckState
  78. ; _GUICtrlListViewSetColumnHeaderText
  79. ; _GUICtrlListViewSetColumnOrder
  80. ; _GUICtrlListViewSetColumnWidth
  81. ; _GUICtrlListViewSetHotItem
  82. ; _GUICtrlListViewSetHoverTime
  83. ; _GUICtrlListViewSetItemCount
  84. ; _GUICtrlListViewSetItemSelState
  85. ; _GUICtrlListViewSetItemText
  86. ; _GUICtrlListViewSort
  87. ;===============================================================================
  88.  
  89. ;===============================================================================
  90. ;
  91. ; Description:            _GUICtrlListViewCopyItems
  92. ; Parameter(s):        $h_Source_listview - controlID
  93. ;                            $h_Destination_listview - control ID
  94. ;                            $i_DelFlag - Delete after copying (Default: 0)
  95. ; Requirement:            None
  96. ; Return Value(s):    None
  97. ; User CallTip:        _GUICtrlListViewCopyItems($h_Source_listview, $h_Destination_listview[, $i_DelFlag = 0]) Copy Items between 2 list-view controls (required: <GuiListView.au3>)
  98. ; Author(s):            Gary Frost (custompcs at charter dot net)
  99. ; Note(s):                :
  100. ;
  101. ;===============================================================================
  102. Func _GUICtrlListViewCopyItems($h_Source_listview, $h_Destination_listview, $i_DelFlag = 0)
  103.     If Not _IsClassName ($h_Source_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, 0)
  104.     If Not _IsClassName ($h_Destination_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, 0)
  105.     Local $a_indices, $i, $s_item, $items
  106.     $items = _GUICtrlListViewGetItemCount($h_Source_listview)
  107.     
  108.     If BitAND(_GUICtrlListViewGetExtendedListViewStyle($h_Source_listview), $LVS_EX_CHECKBOXES) == $LVS_EX_CHECKBOXES Then
  109.         For $i = 0 To $items - 1
  110.             If (_GUICtrlListViewGetCheckedState($h_Source_listview, $i)) Then
  111.                 If IsArray($a_indices) Then
  112.                     ReDim $a_indices[UBound($a_indices) + 1]
  113.                 Else
  114.                     Local $a_indices[2]
  115.                 EndIf
  116.                 $a_indices[0] = $a_indices[0] + 1
  117.                 $a_indices[UBound($a_indices) - 1] = $i
  118.             EndIf
  119.         Next
  120.         
  121.         If (IsArray($a_indices)) Then
  122.             For $i = 1 To $a_indices[0]
  123.                 $s_item = _GUICtrlListViewGetItemText($h_Source_listview, $a_indices[$i])
  124.                 _GUICtrlListViewSetCheckState($h_Source_listview, $a_indices[$i], 0)
  125.                 _GUICtrlListViewInsertItem($h_Destination_listview, _GUICtrlListViewGetItemCount($h_Destination_listview), $s_item)
  126.             Next
  127.             If $i_DelFlag Then
  128.                 For $i = $a_indices[0] To 1 Step - 1
  129.                     _GUICtrlListViewSetItemSelState($h_Source_listview, $a_indices[$i])
  130.                     _GUICtrlListViewDeleteItem($h_Source_listview, $a_indices[$i])
  131.                 Next
  132.             EndIf
  133.         EndIf
  134.     EndIf
  135.     If (_GUICtrlListViewGetSelectedCount($h_Source_listview)) Then
  136.         $a_indices = _GUICtrlListViewGetSelectedIndices($h_Source_listview, 1)
  137.         For $i = 1 To $a_indices[0]
  138.             $s_item = _GUICtrlListViewGetItemText($h_Source_listview, $a_indices[$i])
  139.             _GUICtrlListViewInsertItem($h_Destination_listview, _GUICtrlListViewGetItemCount($h_Destination_listview), $s_item)
  140.         Next
  141.         _GUICtrlListViewSetItemSelState($h_Source_listview, -1, 0)
  142.         If $i_DelFlag Then
  143.             For $i = $a_indices[0] To 1 Step - 1
  144.                 _GUICtrlListViewSetItemSelState($h_Source_listview, $a_indices[$i])
  145.                 _GUICtrlListViewDeleteItem($h_Source_listview, $a_indices[$i])
  146.             Next
  147.         EndIf
  148.     EndIf
  149. EndFunc   ;==>_GUICtrlListViewCopyItems
  150.  
  151. ;===============================================================================
  152. ;
  153. ; Description:            _GUICtrlListViewDeleteAllItems
  154. ; Parameter(s):        $h_listview - controlID
  155. ; Requirement:            None
  156. ; Return Value(s):    Returns TRUE if successful, or FALSE otherwise
  157. ; User CallTip:        _GUICtrlListViewDeleteAllItems($h_listview) Removes all items from a list-view control (required: <GuiListView.au3>)
  158. ; Author(s):            Gary Frost (custompcs at charter dot net)
  159. ; Note(s):                :
  160. ;
  161. ;===============================================================================
  162. Func _GUICtrlListViewDeleteAllItems($h_listview)
  163.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, False)
  164.     Local $i_index, $control_ID
  165.     If IsHWnd($h_listview) Then
  166.         Return _SendMessage($h_listview, $LVM_DELETEALLITEMS)
  167.     Else
  168.         For $i_index = _GUICtrlListViewGetItemCount($h_listview) - 1 To 0 Step - 1
  169.             _GUICtrlListViewSetItemSelState($h_listview, $i_index, 1)
  170.             $control_ID = GUICtrlRead($h_listview)
  171.             If $control_ID Then GUICtrlDelete($control_ID)
  172.         Next
  173.         If _GUICtrlListViewGetItemCount($h_listview) == 0 Then
  174.             Return 1
  175.         Else
  176.             Return GUICtrlSendMsg($h_listview, $LVM_DELETEALLITEMS, 0, 0)
  177.         EndIf
  178.     EndIf
  179. EndFunc   ;==>_GUICtrlListViewDeleteAllItems
  180.  
  181. ;===============================================================================
  182. ;
  183. ; Description:            _GUICtrlListViewDeleteColumn
  184. ; Parameter(s):        $h_listview - controlID
  185. ;                            $i_col - Index of the column to delete
  186. ; Requirement:            None
  187. ; Return Value(s):    Returns TRUE if successful, or FALSE otherwise
  188. ; User CallTip:        _GUICtrlListViewDeleteColumn($h_listview, $i_col) Removes a column from a list-view control (required: <GuiListView.au3>)
  189. ; Author(s):            Gary Frost (custompcs at charter dot net)
  190. ; Note(s):                Column zero of the list-view control cannot be deleted.
  191. ;                            If you must delete column zero, insert a zero length dummy
  192. ;                            column zero and delete column one and above
  193. ;
  194. ;===============================================================================
  195. Func _GUICtrlListViewDeleteColumn($h_listview, $i_col)
  196.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, False)
  197.     If IsHWnd($h_listview) Then
  198.         Return _SendMessage($h_listview, $LVM_DELETECOLUMN, $i_col)
  199.     Else
  200.         Return GUICtrlSendMsg($h_listview, $LVM_DELETECOLUMN, $i_col, 0)
  201.     EndIf
  202. EndFunc   ;==>_GUICtrlListViewDeleteColumn
  203.  
  204. ;===============================================================================
  205. ;
  206. ; Description:            _GUICtrlListViewDeleteItem
  207. ; Parameter(s):        $h_listview - controlID
  208. ;                            $i_index - Index of the list-view item to delete
  209. ; Requirement:            None
  210. ; Return Value(s):    Returns TRUE if successful, or FALSE otherwise
  211. ; User CallTip:        _GUICtrlListViewDeleteItem($h_listview, $i_index) Removes an item from a list-view control (required: <GuiListView.au3>)
  212. ; Author(s):            Gary Frost (custompcs at charter dot net)
  213. ; Note(s):                :
  214. ;
  215. ;===============================================================================
  216. Func _GUICtrlListViewDeleteItem($h_listview, $i_index)
  217.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, False)
  218.     Local $control_ID, $ID_Check
  219.     If IsHWnd($h_listview) Then
  220.         Return _SendMessage($h_listview, $LVM_DELETEITEM, $i_index)
  221.     Else
  222.         _GUICtrlListViewSetItemSelState($h_listview, -1, 0)
  223.         _GUICtrlListViewSetItemSelState($h_listview, $i_index)
  224.         $control_ID = GUICtrlRead($h_listview)
  225.         If $control_ID Then
  226.             GUICtrlDelete($control_ID)
  227.             _GUICtrlListViewSetItemSelState($h_listview, $i_index)
  228.             $ID_Check = GUICtrlRead($h_listview)
  229.             _GUICtrlListViewSetItemSelState($h_listview, $i_index, 0)
  230.             If $control_ID <> $ID_Check Then
  231.                 Return 1
  232.             Else
  233.                 Return GUICtrlSendMsg($h_listview, $LVM_DELETEITEM, $i_index, 0)
  234.             EndIf
  235.         Else
  236.             If Not GUICtrlSendMsg($h_listview, $LVM_DELETEITEM, $i_index, 0) Then
  237.                 Return _SendMessage($h_listview, $LVM_DELETEITEM, $i_index)
  238.             Else
  239.                 Return 1
  240.             EndIf
  241.         EndIf
  242.     EndIf
  243. EndFunc   ;==>_GUICtrlListViewDeleteItem
  244.  
  245. ;===============================================================================
  246. ;
  247. ; Description:            _GUICtrlListViewDeleteItemsSelected
  248. ; Parameter(s):        $h_listview - controlID
  249. ; Requirement:            None
  250. ; Return Value(s):    None
  251. ; User CallTip:        _GUICtrlListViewDeleteItemsSelected($h_listview) Deletes item(s) selected (required: <GuiListView.au3>)
  252. ; Author(s):            Gary Frost (custompcs at charter dot net)
  253. ; Note(s):                Idea from Holger
  254. ;
  255. ;===============================================================================
  256. Func _GUICtrlListViewDeleteItemsSelected($h_listview)
  257.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, 0)
  258.     Local $i, $ItemCount
  259.     
  260.     $ItemCount = _GUICtrlListViewGetItemCount($h_listview)
  261.     If (_GUICtrlListViewGetSelectedCount($h_listview) == $ItemCount) Then
  262.         _GUICtrlListViewDeleteAllItems($h_listview)
  263.     Else
  264.         Local $items = _GUICtrlListViewGetSelectedIndices($h_listview, 1)
  265.         If Not IsArray($items) Then Return SetError($LV_ERR, $LV_ERR, 0)
  266.         _GUICtrlListViewSetItemSelState($h_listview, -1, 0)
  267.         For $i = $items[0] To 1 Step - 1
  268.             _GUICtrlListViewDeleteItem($h_listview, $items[$i])
  269.         Next
  270.     EndIf
  271. EndFunc   ;==>_GUICtrlListViewDeleteItemsSelected
  272.  
  273. ;===============================================================================
  274. ;
  275. ; Description:            _GUICtrlListViewEnsureVisible
  276. ; Parameter(s):        $h_listview - controlID
  277. ;                            $i_index - Index of the list-view item
  278. ;                            $i_bool - Value specifying whether the item must be entirely visible
  279. ; Requirement:            None
  280. ; Return Value(s):    Returns TRUE if successful, or FALSE otherwise
  281. ; User CallTip:        _GUICtrlListViewEnsureVisible($h_listview, $i_index, $i_bool) Ensures that a list-view item is either entirely or partially visible (required: <GuiListView.au3>)
  282. ; Author(s):            Gary Frost (custompcs at charter dot net)
  283. ; Note(s):                If $i_bool parameter is TRUE, no scrolling occurs if the item is at least partially visible
  284. ;
  285. ;===============================================================================
  286. Func _GUICtrlListViewEnsureVisible($h_listview, $i_index, $i_bool)
  287.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, False)
  288.     If IsHWnd($h_listview) Then
  289.         Return _SendMessage($h_listview, $LVM_ENSUREVISIBLE, $i_index, $i_bool)
  290.     Else
  291.         Return GUICtrlSendMsg($h_listview, $LVM_ENSUREVISIBLE, $i_index, $i_bool)
  292.     EndIf
  293. EndFunc   ;==>_GUICtrlListViewEnsureVisible
  294.  
  295. ;===============================================================================
  296. ;
  297. ; Description:            _GUICtrlListViewFindItem
  298. ; Parameter(s):        $h_listview     - controlID
  299. ;                            $v_find            - Text/Item Id to find (See Notes)
  300. ;                            $i_Start            - Index of the item to begin the search with or -1 to start from the beginning.
  301. ;                                                    The specified item is itself excluded from the search. (Optional: Default -1)
  302. ;                            $v_SearchType    - Type of search to perform (See Notes)
  303. ;                            $v_direction    - Virtual key code that specifies the direction to search (See Notes)
  304. ; Requirement:            None
  305. ; Return Value(s):    Returns index if successful, or -1 otherwise
  306. ; User CallTip:        _GUICtrlListViewFindItem($h_listview, $v_find[, $i_Start = -1[, $v_SearchType = 0x8[, $v_direction = 0x28]]]) Searches for a list-view item (required: <GuiListView.au3>)
  307. ; Author(s):            Gary Frost (custompcs at charter dot net)
  308. ; Note(s):
  309. ;    $v_SearchType:
  310. ;        $LVFI_PARAM
  311. ;            Search by Item Id
  312. ;        $LVFI_PARTIAL (Default)
  313. ;            Checks to see if the item text begins with the string pointed to by the psz member.
  314. ;            This value implies use of $LVFI_STRING.
  315. ;        $LVFI_STRING
  316. ;            Searches based on the item text.
  317. ;            Unless additional values are specified, the item text of the matching item must exactly
  318. ;            match the string pointed to by the psz member. However, the search is case-insensitive.
  319. ;        $LVFI_WRAP
  320. ;            Continues the search at the beginning if no match is found
  321. ;
  322. ;    $v_direction
  323. ;        $VK_LEFT
  324. ;        $VK_RIGHT
  325. ;        $VK_UP
  326. ;        $VK_DOWN
  327. ;        $VK_HOME
  328. ;        $VK_END
  329. ;===============================================================================
  330. Func _GUICtrlListViewFindItem($h_listview, $v_find, $i_Start = -1, $v_SearchType = 0x8, $v_direction = 0x28)
  331.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  332.     Local $struct_String, $struct_LVFINDINFO, $iResult
  333.     Local $i_Size, $struct_LVFINDINFO_pointer, $struct_MemMap, $Memory_pointer, $string_Memory_pointer, $sBuffer_pointer
  334.     
  335.     $struct_LVFINDINFO = DllStructCreate("uint;ptr;int;int[2];int")
  336.     If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  337.     DllStructSetData($struct_LVFINDINFO, 1, $v_SearchType)
  338.     If BitAND($v_SearchType, $LVFI_PARAM) = $LVFI_PARAM Then
  339.         DllStructSetData($struct_LVFINDINFO, 3, $v_find)
  340.     Else
  341.         If StringLen($v_find) = 0 Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  342.         $struct_String = DllStructCreate("char[" & StringLen($v_find) + 1 & "]")
  343.         $sBuffer_pointer = DllStructGetPtr($struct_String)
  344.         DllStructSetData($struct_String, 1, $v_find)
  345.     EndIf
  346.     DllStructSetData($struct_LVFINDINFO, 6, $v_direction)
  347.  
  348.     If IsHWnd($h_listview) Then
  349.         $i_Size = DllStructGetSize($struct_LVFINDINFO)
  350.         $struct_LVFINDINFO_pointer = DllStructGetPtr($struct_LVFINDINFO)
  351.         If BitAND($v_SearchType, $LVFI_PARAM) = $LVFI_PARAM Then
  352.             $Memory_pointer = _MemInit ($h_listview, $i_Size, $struct_MemMap)
  353.             If @error Then
  354.                 _MemFree ($struct_MemMap)
  355.                 Return SetError($LV_ERR, $LV_ERR, 0)
  356.             EndIf
  357.             _MemWrite ($struct_MemMap, $struct_LVFINDINFO_pointer)
  358.         Else
  359.             $Memory_pointer = _MemInit ($h_listview, $i_Size + StringLen($v_find) + 1, $struct_MemMap)
  360.             If @error Then
  361.                 _MemFree ($struct_MemMap)
  362.                 Return SetError($LV_ERR, $LV_ERR, 0)
  363.             EndIf
  364.             $string_Memory_pointer = $Memory_pointer + $i_Size
  365.             DllStructSetData($struct_LVFINDINFO, 2, $string_Memory_pointer)
  366.             _MemWrite ($struct_MemMap, $struct_LVFINDINFO_pointer)
  367.             _MemWrite ($struct_MemMap, $sBuffer_pointer, $string_Memory_pointer, 4096)
  368.  
  369.         EndIf
  370.         $iResult = _SendMessage($h_listview, $LVM_FINDITEM, $i_Start, $Memory_pointer)
  371.         If @error Then
  372.             _MemFree ($struct_MemMap)
  373.             Return SetError($LV_ERR, $LV_ERR, 0)
  374.         EndIf
  375.         _MemFree ($struct_MemMap)
  376.         If @error Then Return SetError($LV_ERR, $LV_ERR, 0)
  377.         Return $iResult
  378.     Else
  379.         If BitAND($v_SearchType, $LVFI_PARAM) <> $LVFI_PARAM Then
  380.             DllStructSetData($struct_LVFINDINFO, 2, DllStructGetPtr($struct_String))
  381.         EndIf
  382.         Return GUICtrlSendMsg($h_listview, $LVM_FINDITEM, $i_Start, DllStructGetPtr($struct_LVFINDINFO))
  383.     EndIf
  384. EndFunc   ;==>_GUICtrlListViewFindItem
  385.  
  386. ;===============================================================================
  387. ;
  388. ; Description:            _GUICtrlListViewGetBackColor
  389. ; Parameter(s):        $h_listview - controlID
  390. ; Requirement:            _ReverseColorOrder
  391. ; Return Value(s):    Returns the Hex RGB background color of the list-view control
  392. ; User CallTip:        _GUICtrlListViewGetBackColor($h_listview) Retrieves the background color of a list-view control (required: <GuiListView.au3>)
  393. ; Author(s):            Gary Frost (custompcs at charter dot net)
  394. ; Note(s):                :
  395. ;
  396. ;===============================================================================
  397. Func _GUICtrlListViewGetBackColor($h_listview)
  398.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  399.     Local $v_color
  400.     If IsHWnd($h_listview) Then
  401.         $v_color = _SendMessage($h_listview, $LVM_GETBKCOLOR)
  402.     Else
  403.         $v_color = GUICtrlSendMsg($h_listview, $LVM_GETBKCOLOR, 0, 0)
  404.     EndIf
  405.     Return _ReverseColorOrder($v_color)
  406. EndFunc   ;==>_GUICtrlListViewGetBackColor
  407.  
  408. ;===============================================================================
  409. ;
  410. ; Description:            _GUICtrlListViewGetCallBackMask
  411. ; Parameter(s):        $h_listview - controlID
  412. ; Requirement:            None
  413. ; Return Value(s):    Returns the callback mask
  414. ; User CallTip:        _GUICtrlListViewGetCallBackMask($h_listview) Retrieves the callback mask for a list-view control (required: <GuiListView.au3>)
  415. ; Author(s):            Gary Frost (custompcs at charter dot net)
  416. ; Note(s):                :
  417. ;
  418. ;===============================================================================
  419. Func _GUICtrlListViewGetCallBackMask($h_listview)
  420.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  421.     If IsHWnd($h_listview) Then
  422.         Return _SendMessage($h_listview, $LVM_GETCALLBACKMASK)
  423.     Else
  424.         Return GUICtrlSendMsg($h_listview, $LVM_GETCALLBACKMASK, 0, 0)
  425.     EndIf
  426. EndFunc   ;==>_GUICtrlListViewGetCallBackMask
  427.  
  428. ;===============================================================================
  429. ;
  430. ; Description:            _GUICtrlListViewGetCheckedState
  431. ; Parameter(s):        $h_listview - controlID
  432. ;                            $i_index - zero-based index to retrieve item check state from
  433. ; Requirement:            $LVS_EX_CHECKBOXES used in extended style when creating listview
  434. ; Return Value(s):    Returns 1 if checked
  435. ;                            Returns 0 if not checked
  436. ;                            If error then $LV_ERR is returned
  437. ; User CallTip:        _GUICtrlListViewGetCheckedState($h_listview, $i_index) Returns the check state for a list-view control item (required: <GuiListView.au3>)
  438. ; Author(s):            Gary Frost (custompcs at charter dot net)
  439. ; Note(s):                :
  440. ;
  441. ;===============================================================================
  442. Func _GUICtrlListViewGetCheckedState($h_listview, $i_index)
  443.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  444.     Local $isChecked = 0, $ret
  445.     If IsHWnd($h_listview) Then
  446.         $ret = _SendMessage($h_listview, $LVM_GETITEMSTATE, $i_index, $LVIS_STATEIMAGEMASK)
  447.     Else
  448.         $ret = GUICtrlSendMsg($h_listview, $LVM_GETITEMSTATE, $i_index, $LVIS_STATEIMAGEMASK)
  449.     EndIf
  450.     If (Not $ret) Then
  451.         $ret = _SendMessage($h_listview, $LVM_GETITEMSTATE, $i_index, $LVIS_STATEIMAGEMASK)
  452.         If ($ret == -1) Then
  453.             Return $LV_ERR
  454.         Else
  455.             If (BitAND($ret, 0x3000) == 0x3000) Then
  456.                 $isChecked = 0
  457.             Else
  458.                 $isChecked = 1
  459.             EndIf
  460.         EndIf
  461.     Else
  462.         If (BitAND($ret, 0x2000) == 0x2000) Then $isChecked = 1
  463.     EndIf
  464.     Return $isChecked
  465. EndFunc   ;==>_GUICtrlListViewGetCheckedState
  466.  
  467. ;===============================================================================
  468. ;
  469. ; Description:            _GUICtrlListViewGetColumnOrder
  470. ; Parameter(s):        $h_listview - controlID
  471. ; Requirement:            None
  472. ; Return Value(s):    "|" delimited string
  473. ;                            If an error occurs, the return value is $LV_ERR.
  474. ; User CallTip:        _GUICtrlListViewGetColumnOrder($h_listview) Retrieves the current left-to-right order of columns in a list-view control. (required: <GuiListView.au3>)
  475. ; Author(s):            Gary Frost (custompcs at charter dot net)
  476. ; Note(s):
  477. ;
  478. ;===============================================================================
  479. Func _GUICtrlListViewGetColumnOrder($h_listview)
  480.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  481.     Local $i_cols = _GUICtrlListViewGetSubItemsCount($h_listview)
  482.     Local $i, $ret
  483.     Local $struct = ""
  484.     For $i = 1 To $i_cols
  485.         $struct &= "int;"
  486.     Next
  487.     $struct = StringTrimRight($struct, 1)
  488.     Local $column_struct = DllStructCreate($struct)
  489.     If @error Then Return $LV_ERR
  490.     If IsHWnd($h_listview) Then
  491.         Local $struct_MemMap, $sBuffer_pointer
  492.         $sBuffer_pointer = DllStructGetPtr($column_struct)
  493.         Local $i_Size = DllStructGetSize($column_struct)
  494.         Local $Memory_pointer = _MemInit ($h_listview, $i_Size, $struct_MemMap)
  495.         If @error Then
  496.             _MemFree ($struct_MemMap)
  497.             Return SetError($LV_ERR, $LV_ERR, 0)
  498.         EndIf
  499.         $ret = _SendMessage($h_listview, $LVM_GETCOLUMNORDERARRAY, $i_cols, $Memory_pointer)
  500.         If @error Then
  501.             _MemFree ($struct_MemMap)
  502.             Return SetError($LV_ERR, $LV_ERR, 0)
  503.         EndIf
  504.         _MemRead ($struct_MemMap, $Memory_pointer, $sBuffer_pointer, $i_Size)
  505.         If @error Then
  506.             _MemFree ($struct_MemMap)
  507.             Return SetError($LV_ERR, $LV_ERR, 0)
  508.         EndIf
  509.         _MemFree ($struct_MemMap)
  510.         If @error Then Return SetError($LV_ERR, $LV_ERR, 0)
  511.     Else
  512.         $ret = GUICtrlSendMsg($h_listview, $LVM_GETCOLUMNORDERARRAY, $i_cols, DllStructGetPtr($column_struct))
  513.     EndIf
  514.     If (Not $ret) Then Return $LV_ERR
  515.     Local $s_cols
  516.     For $i = 1 To $i_cols
  517.         $s_cols &= DllStructGetData($column_struct, $i) & "|"
  518.     Next
  519.     $s_cols = StringTrimRight($s_cols, 1)
  520.     Return $s_cols
  521. EndFunc   ;==>_GUICtrlListViewGetColumnOrder
  522.  
  523. ;===============================================================================
  524. ;
  525. ; Description:            _GUICtrlListViewGetColumnWidth
  526. ; Parameter(s):        $h_listview - controlID
  527. ;                            $i_col - Index of the column. This parameter is ignored in list view
  528. ; Requirement:            None
  529. ; Return Value(s):    Returns the column width if successful, or zero otherwise
  530. ; User CallTip:        _GUICtrlListViewGetColumnWidth($h_listview, $i_col) Retrieves the width of a column in report or list view (required: <GuiListView.au3>)
  531. ; Author(s):            Gary Frost (custompcs at charter dot net)
  532. ; Note(s):                If this message is sent to a list-view control with the LVS_REPORT style
  533. ;                            and the specified column doesn't exist, the return value is undefined
  534. ;
  535. ;===============================================================================
  536. Func _GUICtrlListViewGetColumnWidth($h_listview, $i_col)
  537.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, 0)
  538.     If IsHWnd($h_listview) Then
  539.         Return _SendMessage($h_listview, $LVM_GETCOLUMNWIDTH, $i_col)
  540.     Else
  541.         Return GUICtrlSendMsg($h_listview, $LVM_GETCOLUMNWIDTH, $i_col, 0)
  542.     EndIf
  543. EndFunc   ;==>_GUICtrlListViewGetColumnWidth
  544.  
  545. ;===============================================================================
  546. ;
  547. ; Description:            _GUICtrlListViewGetCounterPage
  548. ; Parameter(s):        $h_listview - controlID
  549. ; Requirement:            None
  550. ; Return Value(s):    Returns the number of fully visible items if successful.
  551. ;                            If the current view is icon or small icon view, the return value
  552. ;                            is the total number of items in the list-view control.
  553. ; User CallTip:        _GUICtrlListViewGetCounterPage($h_listview) Calculates the number of items that can fit vertically in the visible area of a list-view control (required: <GuiListView.au3>)
  554. ; Author(s):            Gary Frost (custompcs at charter dot net)
  555. ; Note(s):                :
  556. ;
  557. ;===============================================================================
  558. Func _GUICtrlListViewGetCounterPage($h_listview)
  559.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  560.     If IsHWnd($h_listview) Then
  561.         Return _SendMessage($h_listview, $LVM_GETCOUNTPERPAGE)
  562.     Else
  563.         Return GUICtrlSendMsg($h_listview, $LVM_GETCOUNTPERPAGE, 0, 0)
  564.     EndIf
  565. EndFunc   ;==>_GUICtrlListViewGetCounterPage
  566.  
  567. ;===============================================================================
  568. ;
  569. ; Description:            _GUICtrlListViewGetCurSel
  570. ; Parameter(s):        $h_listview - controlID
  571. ; Requirement:            None
  572. ; Return Value(s):    Index of current selection (zero-based index)
  573. ;                            returns $LV_ERR if error
  574. ; User CallTip:        _GUICtrlListViewGetCurSel($h_listview) Retrieve the index of current selection (required: <GuiListView.au3>)
  575. ; Author(s):            Gary Frost (custompcs at charter dot net)
  576. ; Note(s):                :
  577. ;
  578. ;===============================================================================
  579. Func _GUICtrlListViewGetCurSel($h_listview)
  580.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  581.     If _GUICtrlListViewGetSelectedCount($h_listview) > 0 Then
  582.         Return Int(_GUICtrlListViewGetSelectedIndices($h_listview))
  583.     Else
  584.         Return $LV_ERR
  585.     EndIf
  586. EndFunc   ;==>_GUICtrlListViewGetCurSel
  587.  
  588. ;===============================================================================
  589. ;
  590. ; Description:            _GUICtrlListViewGetExtendedListViewStyle
  591. ; Parameter(s):        $h_listview - controlID
  592. ; Requirement:            None
  593. ; Return Value(s):    Returns a DWORD that represents the styles currently in use for a given list-view control.
  594. ;                            This value can be a combination of Extended List-View Styles
  595. ; User CallTip:        _GUICtrlListViewGetExtendedListViewStyle($h_listview) Retrieves the extended styles that are currently in use for a given list-view control (required: <GuiListView.au3>)
  596. ; Author(s):            Gary Frost (custompcs at charter dot net)
  597. ; Note(s):                :
  598. ;
  599. ;===============================================================================
  600. Func _GUICtrlListViewGetExtendedListViewStyle($h_listview)
  601.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  602.     If IsHWnd($h_listview) Then
  603.         Return _SendMessage($h_listview, $LVM_GETEXTENDEDLISTVIEWSTYLE)
  604.     Else
  605.         Return GUICtrlSendMsg($h_listview, $LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
  606.     EndIf
  607. EndFunc   ;==>_GUICtrlListViewGetExtendedListViewStyle
  608.  
  609. ;===============================================================================
  610. ;
  611. ; Description:            _GUICtrlListViewGetHeader
  612. ; Parameter(s):        $h_listview - controlID
  613. ; Requirement:            None
  614. ; Return Value(s):    Returns the handle to the header control.
  615. ; User CallTip:        _GUICtrlListViewGetHeader($h_listview) Retrieves the handle to the header control used by the list-view control (required: <GuiListView.au3>)
  616. ; Author(s):            Gary Frost (custompcs at charter dot net)
  617. ; Note(s):                :
  618. ;
  619. ;===============================================================================
  620. Func _GUICtrlListViewGetHeader($h_listview)
  621.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  622.     If IsHWnd($h_listview) Then
  623.         Return _SendMessage($h_listview, $LVM_GETHEADER)
  624.     Else
  625.         Return GUICtrlSendMsg($h_listview, $LVM_GETHEADER, 0, 0)
  626.     EndIf
  627. EndFunc   ;==>_GUICtrlListViewGetHeader
  628.  
  629. ;===============================================================================
  630. ;
  631. ; Description:            _GUICtrlListViewGetHotCursor
  632. ; Parameter(s):        $h_listview - controlID
  633. ; Requirement:            None
  634. ; Return Value(s):    Returns an HCURSOR value that is the handle to the cursor that
  635. ;                            the list-view control uses when hot tracking is enabled.
  636. ; User CallTip:        _GUICtrlListViewGetHotCursor($h_listview) Retrieves the HCURSOR value used when the pointer is over an item while hot tracking is enabled (required: <GuiListView.au3>)
  637. ; Author(s):            Gary Frost (custompcs at charter dot net)
  638. ; Note(s):                A list-view control uses hot tracking and hover selection when
  639. ;                            the LVS_EX_TRACKSELECT style is set.
  640. ;
  641. ;===============================================================================
  642. Func _GUICtrlListViewGetHotCursor($h_listview)
  643.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  644.     If IsHWnd($h_listview) Then
  645.         Return _SendMessage($h_listview, $LVM_GETHOTCURSOR)
  646.     Else
  647.         Return GUICtrlSendMsg($h_listview, $LVM_GETHOTCURSOR, 0, 0)
  648.     EndIf
  649. EndFunc   ;==>_GUICtrlListViewGetHotCursor
  650.  
  651. ;===============================================================================
  652. ;
  653. ; Description:            _GUICtrlListViewGetHotItem
  654. ; Parameter(s):        $h_listview - controlID
  655. ; Requirement:            None
  656. ; Return Value(s):    Returns the index of the item that is hot.
  657. ; User CallTip:        _GUICtrlListViewGetHotItem($h_listview) Retrieves the index of the hot item (required: <GuiListView.au3>)
  658. ; Author(s):            Gary Frost (custompcs at charter dot net)
  659. ; Note(s):                :
  660. ;
  661. ;===============================================================================
  662. Func _GUICtrlListViewGetHotItem($h_listview)
  663.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  664.     If IsHWnd($h_listview) Then
  665.         Return _SendMessage($h_listview, $LVM_GETHOTITEM)
  666.     Else
  667.         Return GUICtrlSendMsg($h_listview, $LVM_GETHOTITEM, 0, 0)
  668.     EndIf
  669. EndFunc   ;==>_GUICtrlListViewGetHotItem
  670.  
  671. ;===============================================================================
  672. ;
  673. ; Description:            _GUICtrlListViewGetHoverTime
  674. ; Parameter(s):        $h_listview - controlID
  675. ; Requirement:            None
  676. ; Return Value(s):    Returns the amount of time, in milliseconds,
  677. ;                            that the mouse cursor must hover over an item
  678. ;                            before it is selected.
  679. ;                            If the return value is -1, then the hover
  680. ;                            time is the default hover time.
  681. ; User CallTip:        _GUICtrlListViewGetHoverTime($h_listview) Retrieves the amount of time that the mouse cursor must hover over an item before it is selected (required: <GuiListView.au3>)
  682. ; Author(s):            Gary Frost (custompcs at charter dot net)
  683. ; Note(s):                The hover time only affects list-view controls that have the
  684. ;                            LVS_EX_TRACKSELECT, LVS_EX_ONECLICKACTIVATE, or
  685. ;                            LVS_EX_TWOCLICKACTIVATE extended list-view style.
  686. ;
  687. ;===============================================================================
  688. Func _GUICtrlListViewGetHoverTime($h_listview)
  689.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  690.     If IsHWnd($h_listview) Then
  691.         Return _SendMessage($h_listview, $LVM_GETHOVERTIME)
  692.     Else
  693.         Return GUICtrlSendMsg($h_listview, $LVM_GETHOVERTIME, 0, 0)
  694.     EndIf
  695. EndFunc   ;==>_GUICtrlListViewGetHoverTime
  696.  
  697. ;===============================================================================
  698. ;
  699. ; Description:            _GUICtrlListViewGetItemCount
  700. ; Parameter(s):        $h_listview - controlID
  701. ; Requirement:            None
  702. ; Return Value(s):    Returns the number of items.
  703. ; User CallTip:        _GUICtrlListViewGetItemCount($h_listview) Retrieves the number of items in a list-view control (required: <GuiListView.au3>)
  704. ; Author(s):            Gary Frost (custompcs at charter dot net)
  705. ; Note(s):                :
  706. ;
  707. ;===============================================================================
  708. Func _GUICtrlListViewGetItemCount($h_listview)
  709.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  710.     If IsHWnd($h_listview) Then
  711.         Return _SendMessage($h_listview, $LVM_GETITEMCOUNT)
  712.     Else
  713.         Return GUICtrlSendMsg($h_listview, $LVM_GETITEMCOUNT, 0, 0)
  714.     EndIf
  715. EndFunc   ;==>_GUICtrlListViewGetItemCount
  716.  
  717. ;===============================================================================
  718. ;
  719. ; Description:            _GUICtrlListViewGetItemText
  720. ; Parameter(s):        $h_listview - controlID
  721. ;                            $i_Item - index of item to retrieve from (zero-based index)
  722. ;                            $i_SubItem - column of item to retrieve from (zero-based index)
  723. ; Requirement:            None
  724. ; Return Value(s):    If $i_SubItem = -1 then row is returned pipe delimited
  725. ;                            else text from $i_SubItem position is returned
  726. ;                            If error $LV_ERR is returned
  727. ; User CallTip:        _GUICtrlListViewGetItemText($h_listview[, $i_Item=-1[, $i_SubItem=-1]]) Retrieves some or all of a list-view item (required: <GuiListView.au3>)
  728. ; Author(s):            Gary Frost (custompcs at charter dot net)
  729. ; Note(s):                :
  730. ;
  731. ;===============================================================================
  732. Func _GUICtrlListViewGetItemText($h_listview, $i_Item = -1, $i_SubItem = -1)
  733.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  734.     Local $sBuffer_pointer
  735.     Local $LVITEM_pointer
  736.     Local $Memory_pointer, $struct_MemMap
  737.     Local $i_Size, $string_Memory_pointer
  738.     Local $struct_LVITEM, $struct_String
  739.  
  740.     $struct_LVITEM = DllStructCreate($LVITEM)
  741.     If @error Then Return SetError($LV_ERR, $LV_ERR, "")
  742.     $struct_String = DllStructCreate("char[4096]")
  743.     If @error Then Return SetError($LV_ERR, $LV_ERR, "")
  744.     If $i_Item = -1 Then $i_Item = Int(_GUICtrlListViewGetSelectedIndices($h_listview))
  745.     If $i_Item = -1 Then Return SetError($LV_ERR, $LV_ERR, "")
  746.  
  747.     DllStructSetData($struct_LVITEM, $LVI_MASK, $LVIF_TEXT)
  748.     DllStructSetData($struct_LVITEM, $LVI_CCHTEXTMAX, 4096)
  749.  
  750.     Local $x_indice, $count, $str = ""
  751.  
  752.     $count = _GUICtrlListViewGetSubItemsCount($h_listview)
  753.     If Not $count Then $count = 1
  754.  
  755.     DllStructSetData($struct_LVITEM, $LVI_IITEM, $i_Item)
  756.     If ($i_SubItem == -1) Then; return all the subitems in the item
  757.         For $x_indice = 0 To $count - 1 Step 1
  758.             If IsHWnd($h_listview) Then
  759.  
  760.                 $sBuffer_pointer = DllStructGetPtr($struct_String)
  761.                 $LVITEM_pointer = DllStructGetPtr($struct_LVITEM)
  762.                 $i_Size = DllStructGetSize($struct_LVITEM)
  763.                 $Memory_pointer = _MemInit ($h_listview, $i_Size + 4096, $struct_MemMap)
  764.                 If @error Then
  765.                     _MemFree ($struct_MemMap)
  766.                     Return SetError($LV_ERR, $LV_ERR, "")
  767.                 EndIf
  768.                 $string_Memory_pointer = $Memory_pointer + 4096
  769.                 DllStructSetData($struct_LVITEM, $LVI_ISUBITEM, $x_indice)
  770.                 DllStructSetData($struct_LVITEM, $LVI_PSZTEXT, $string_Memory_pointer)
  771.                 _MemWrite ($struct_MemMap, $LVITEM_pointer)
  772.                 If @error Then
  773.                     _MemFree ($struct_MemMap)
  774.                     Return SetError($LV_ERR, $LV_ERR, "")
  775.                 EndIf
  776.                 _SendMessage($h_listview, $LVM_GETITEMA, 0, $Memory_pointer)
  777.                 If @error Then
  778.                     _MemFree ($struct_MemMap)
  779.                     Return SetError($LV_ERR, $LV_ERR, "")
  780.                 EndIf
  781.                 _MemRead ($struct_MemMap, $string_Memory_pointer, $sBuffer_pointer, 4096)
  782.                 If @error Then
  783.                     _MemFree ($struct_MemMap)
  784.                     Return SetError($LV_ERR, $LV_ERR, "")
  785.                 EndIf
  786.                 _MemFree ($struct_MemMap)
  787.                 If @error Then Return SetError($LV_ERR, $LV_ERR, "")
  788.             Else
  789.                 DllStructSetData($struct_LVITEM, $LVI_PSZTEXT, DllStructGetPtr($struct_String))
  790.                 DllStructSetData($struct_LVITEM, $LVI_ISUBITEM, $x_indice)
  791.                 If Not GUICtrlSendMsg($h_listview, $LVM_GETITEMA, 0, DllStructGetPtr($struct_LVITEM)) Then
  792.                     SetError($LV_ERR)
  793.                 EndIf
  794.             EndIf
  795.             If Not @error Then
  796.                 If $x_indice Then
  797.                     $str = $str & "|" & DllStructGetData($struct_String, 1)
  798.                 Else
  799.                     $str = DllStructGetData($struct_String, 1)
  800.                 EndIf
  801.             Else
  802.                 If StringLen($str) Then
  803.                     $str = $str & "|"
  804.                 EndIf
  805.             EndIf
  806.         Next
  807.         Return $str
  808.     ElseIf ($i_SubItem < $count) Then; return the subitem in the item
  809.         If IsHWnd($h_listview) Then
  810.             $sBuffer_pointer = DllStructGetPtr($struct_String)
  811.             $LVITEM_pointer = DllStructGetPtr($struct_LVITEM)
  812.             $i_Size = DllStructGetSize($struct_LVITEM)
  813.             $Memory_pointer = _MemInit ($h_listview, $i_Size + 4096, $struct_MemMap)
  814.             If @error Then
  815.                 _MemFree ($struct_MemMap)
  816.                 Return SetError($LV_ERR, $LV_ERR, "")
  817.             EndIf
  818.             $string_Memory_pointer = $Memory_pointer + 4096
  819.             DllStructSetData($struct_LVITEM, $LVI_ISUBITEM, $i_SubItem)
  820.             DllStructSetData($struct_LVITEM, $LVI_PSZTEXT, $string_Memory_pointer)
  821.             _MemWrite ($struct_MemMap, $LVITEM_pointer)
  822.             If @error Then
  823.                 _MemFree ($struct_MemMap)
  824.                 Return SetError($LV_ERR, $LV_ERR, "")
  825.             EndIf
  826.             _SendMessage($h_listview, $LVM_GETITEMA, 0, $Memory_pointer)
  827.             If @error Then
  828.                 _MemFree ($struct_MemMap)
  829.                 Return SetError($LV_ERR, $LV_ERR, "")
  830.             EndIf
  831.             _MemRead ($struct_MemMap, $string_Memory_pointer, $sBuffer_pointer, 4096)
  832.             If @error Then
  833.                 _MemFree ($struct_MemMap)
  834.                 Return SetError($LV_ERR, $LV_ERR, "")
  835.             EndIf
  836.             _MemFree ($struct_MemMap)
  837.             If @error Then Return SetError($LV_ERR, $LV_ERR, "")
  838.         Else
  839.             DllStructSetData($struct_LVITEM, $LVI_PSZTEXT, DllStructGetPtr($struct_String))
  840.             DllStructSetData($struct_LVITEM, $LVI_ISUBITEM, $i_SubItem)
  841.             If Not GUICtrlSendMsg($h_listview, $LVM_GETITEMA, 0, DllStructGetPtr($struct_LVITEM)) Then Return SetError($LV_ERR, $LV_ERR, "")
  842.         EndIf
  843.         Return DllStructGetData($struct_String, 1)
  844.     Else
  845.         ; subitem is out of range
  846.         Return SetError($LV_ERR, $LV_ERR, "")
  847.     EndIf
  848. EndFunc   ;==>_GUICtrlListViewGetItemText
  849.  
  850. ;===============================================================================
  851. ;
  852. ; Description:            _GUICtrlListViewGetItemTextArray
  853. ; Parameter(s):        $h_listview - controlID/handle
  854. ;                            $i_Item - index of item to retrieve from (zero-based index)
  855. ; Requirement:            None
  856. ; Return Value(s):    Returns an array of the subitems
  857. ;                            If $i_Item = -1 current selection is used
  858. ;                            If error $LV_ERR is returned
  859. ; User CallTip:        _GUICtrlListViewGetItemTextA($h_listview[, $i_Item=-1]) Retrieves all of a list-view item (required: <GuiListView.au3>)
  860. ; Author(s):            Gary Frost (custompcs at charter dot net)
  861. ; Note(s):                :
  862. ;
  863. ;===============================================================================
  864. Func _GUICtrlListViewGetItemTextArray($h_listview, $i_Item = -1)
  865.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  866.     Local $v_ret = _GUICtrlListViewGetItemText($h_listview, $i_Item)
  867.     If @error Or $v_ret = "" Then Return SetError($LV_ERR, $LV_ERR, "")
  868.     Return StringSplit($v_ret, "|")
  869. EndFunc   ;==>_GUICtrlListViewGetItemTextArray
  870.  
  871. ;===============================================================================
  872. ;
  873. ; Description:            _GUICtrlListViewGetNextItem
  874. ; Parameter(s):        $h_GUI - GUI Window handle
  875. ;                            $h_listview - controlID
  876. ;                            $i_index - Index of the item to begin the search with
  877. ;                            $i_direction - Specifies the relationship to the item specified in $i_index
  878. ; Requirement:            None
  879. ; Return Value(s):    Returns the index of the next item if successful, or $LV_ERR otherwise.
  880. ; User CallTip:        _GUICtrlListViewGetNextItem($h_GUI, $h_listview[, $i_index=-1[, $i_direction=0x0]]) Returns the index of the next item (required: <GuiListView.au3>)
  881. ; Author(s):            Gary Frost (custompcs at charter dot net)
  882. ; Note(s):                If $i_index = -1 then find the first item that matches the specified $i_direction.
  883. ;                            The specified item itself is excluded from the search.
  884. ;
  885. ;                            $i_direction
  886. ;                                Searches by index.
  887. ;                                    $LVNI_ALL
  888. ;                                        Searches for a subsequent item by index, the default value.
  889. ;                                Searches by physical relationship to the index of the item where the search is to begin.
  890. ;                                    $LVNI_ABOVE
  891. ;                                        Searches for an item that is above the specified item.
  892. ;                                    $LVNI_BELOW
  893. ;                                        Searches for an item that is below the specified item.
  894. ;                                    $LVNI_TOLEFT
  895. ;                                        Searches for an item to the left of the specified item.
  896. ;                                    $LVNI_TORIGHT
  897. ;                                        Searches for an item to the right of the specified item.
  898. ;
  899. ;===============================================================================
  900. Func _GUICtrlListViewGetNextItem($h_GUI, $h_listview, $i_index = -1, $i_direction = 0x0)
  901.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  902.     Local $h_lv
  903.     If IsHWnd($h_listview) Then
  904.         $h_lv = $h_listview
  905.     Else
  906.         $h_lv = ControlGetHandle($h_GUI, "", $h_listview)
  907.     EndIf
  908.     If ($i_direction == $LVNI_ALL Or $i_direction == $LVNI_ABOVE Or _
  909.             $i_direction == $LVNI_BELOW Or $i_direction == $LVNI_TOLEFT Or _
  910.             $i_direction == $LVNI_TORIGHT) Then
  911.         Return _SendMessage($h_lv, $LVM_GETNEXTITEM, $i_index, $i_direction)
  912.     Else
  913.         Return $LV_ERR
  914.     EndIf
  915. EndFunc   ;==>_GUICtrlListViewGetNextItem
  916.  
  917. ;===============================================================================
  918. ;
  919. ; Description:            _GUICtrlListViewGetSelectedCount
  920. ; Parameter(s):        $h_listview - controlID
  921. ; Requirement:            None
  922. ; Return Value(s):    Returns the number of selected items
  923. ; User CallTip:        _GUICtrlListViewGetSelectedCount($h_listview) Determines the number of selected items in a list-view control (required: <GuiListView.au3>)
  924. ; Author(s):            Gary Frost (custompcs at charter dot net)
  925. ; Note(s):                :
  926. ;
  927. ;===============================================================================
  928. Func _GUICtrlListViewGetSelectedCount($h_listview)
  929.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  930.     If IsHWnd($h_listview) Then
  931.         Return _SendMessage($h_listview, $LVM_GETSELECTEDCOUNT)
  932.     Else
  933.         Return GUICtrlSendMsg($h_listview, $LVM_GETSELECTEDCOUNT, 0, 0)
  934.     EndIf
  935. EndFunc   ;==>_GUICtrlListViewGetSelectedCount
  936.  
  937. ;===============================================================================
  938. ;
  939. ; Description:            _GUICtrlListViewGetSelectedIndices
  940. ; Parameter(s):        $h_listview - controlID
  941. ;                            $i_ReturnType - Optional: return a string or array
  942. ; Requirement:            None
  943. ; Return Value(s):    If $i_ReturnType = 0 then Return pipe delimited string of indices of selected item(s)
  944. ;                            If $i_ReturnType = 1 then Return array of indices of selected item(s)
  945. ;                            If no items selected return $LV_ERR
  946. ; User CallTip:        _GUICtrlListViewGetSelectedIndices($h_listview[, $i_ReturnType=0]) Retrieve indices of selected item(s) in a list-view control (required: <GuiListView.au3>)
  947. ; Author(s):            Gary Frost (custompcs at charter dot net)
  948. ; Note(s):                :
  949. ;
  950. ;===============================================================================
  951. Func _GUICtrlListViewGetSelectedIndices($h_listview, $i_ReturnType = 0)
  952.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  953.     Local $v_indices
  954.     Local $x_indice, $v_ret
  955.     For $x_indice = 0 To _GUICtrlListViewGetItemCount($h_listview)
  956.         If IsHWnd($h_listview) Then
  957.             $v_ret = _SendMessage($h_listview, $LVM_GETITEMSTATE, $x_indice, $LVIS_SELECTED)
  958.             If $v_ret Then
  959.                 If (Not $i_ReturnType) Then
  960.                     If StringLen($v_indices) Then
  961.                         $v_indices = $v_indices & "|" & $x_indice
  962.                     Else
  963.                         $v_indices = $x_indice
  964.                     EndIf
  965.                 Else
  966.                     If Not IsArray($v_indices) Then
  967.                         Dim $v_indices[2]
  968.                     Else
  969.                         ReDim $v_indices[UBound($v_indices) + 1]
  970.                     EndIf
  971.                     $v_indices[0] = UBound($v_indices) - 1
  972.                     $v_indices[UBound($v_indices) - 1] = $x_indice
  973.                 EndIf
  974.             EndIf
  975.         Else
  976.             $v_ret = GUICtrlSendMsg($h_listview, $LVM_GETITEMSTATE, $x_indice, $LVIS_SELECTED)
  977.             If $v_ret Then
  978.                 If (Not $i_ReturnType) Then
  979.                     If StringLen($v_indices) Then
  980.                         $v_indices = $v_indices & "|" & $x_indice
  981.                     Else
  982.                         $v_indices = $x_indice
  983.                     EndIf
  984.                 Else
  985.                     If Not IsArray($v_indices) Then
  986.                         Dim $v_indices[2]
  987.                     Else
  988.                         ReDim $v_indices[UBound($v_indices) + 1]
  989.                     EndIf
  990.                     $v_indices[0] = UBound($v_indices) - 1
  991.                     $v_indices[UBound($v_indices) - 1] = $x_indice
  992.                 EndIf
  993.             EndIf
  994.         EndIf
  995.     Next
  996.     If (StringLen($v_indices) > 0 Or IsArray($v_indices)) Then
  997.         Return $v_indices
  998.     Else
  999.         Return $LV_ERR
  1000.     EndIf
  1001. EndFunc   ;==>_GUICtrlListViewGetSelectedIndices
  1002.  
  1003. ;===============================================================================
  1004. ;
  1005. ; Description:            _GUICtrlListViewGetSubItemsCount
  1006. ; Parameter(s):        $h_listview - controlID/handle
  1007. ; Requirement:            None
  1008. ; Return Value(s):    Number of columns
  1009. ; User CallTip:        _GUICtrlListViewGetSubItemsCount(ByRef $h_listview) Retrieve the number of columns (required: <GuiListView.au3>)
  1010. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1011. ; Note(s):                :
  1012. ;
  1013. ;===============================================================================
  1014. Func _GUICtrlListViewGetSubItemsCount($h_listview)
  1015.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1016. ;~     Local Const $HDM_GETITEMCOUNT = 0x1200
  1017.     Return _SendMessage(_GUICtrlListViewGetHeader($h_listview), 0x1200, 0, 0)
  1018. EndFunc   ;==>_GUICtrlListViewGetSubItemsCount
  1019.  
  1020. ;===============================================================================
  1021. ;
  1022. ; Description:            _GUICtrlListViewGetTopIndex
  1023. ; Parameter(s):        $h_listview - controlID
  1024. ; Requirement:            None
  1025. ; Return Value(s):    Returns the index of the item if successful
  1026. ;                            zero if the list-view control is in icon or small icon view.
  1027. ; User CallTip:        _GUICtrlListViewGetTopIndex($h_listview) Retrieves the index of the topmost visible item when in list or report view (required: <GuiListView.au3>)
  1028. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1029. ; Note(s):                :
  1030. ;
  1031. ;===============================================================================
  1032. Func _GUICtrlListViewGetTopIndex($h_listview)
  1033.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1034.     If IsHWnd($h_listview) Then
  1035.         Return _SendMessage($h_listview, $LVM_GETTOPINDEX)
  1036.     Else
  1037.         Return GUICtrlSendMsg($h_listview, $LVM_GETTOPINDEX, 0, 0)
  1038.     EndIf
  1039. EndFunc   ;==>_GUICtrlListViewGetTopIndex
  1040.  
  1041. ;===============================================================================
  1042. ;
  1043. ; Description:            _GUICtrlListViewGetUnicodeFormat
  1044. ; Parameter(s):        $h_listview - controlID
  1045. ; Requirement:            None
  1046. ; Return Value(s):    If this value is nonzero, the control is using Unicode characters.
  1047. ;                            If this value is zero, the control is using ANSI characters.
  1048. ; User CallTip:        _GUICtrlListViewGetUnicodeFormat($h_listview) Retrieves the UNICODE character format flag for the control (required: <GuiListView.au3>)
  1049. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1050. ; Note(s):                The Unicode format flag is used by Microsoft Windows NT systems
  1051. ;                            with version 4.71 of Comctl32.dll or later. This message is, thus,
  1052. ;                            supported by Windows 2000 and later, and by Windows NT 4 with Microsoft
  1053. ;                            Internet Explorer 4.0 or later. It is only useful on Windows 95 or Windows 98
  1054. ;                            systems with version 5.80 or later of Comctl32.dll.
  1055. ;
  1056. ;                            This means that they must have Internet Explorer 5 or later installed.
  1057. ;                            Windows 95 and Windows 98 systems with earlier versions of Internet Explorer
  1058. ;                            ignore the Unicode format flag, and its value has no bearing on whether a control
  1059. ;                            supports Unicode. With these systems, you will instead need to test something that
  1060. ;                            requires Unicode support.
  1061. ;
  1062. ;===============================================================================
  1063. Func _GUICtrlListViewGetUnicodeFormat($h_listview)
  1064.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, 0)
  1065.     If IsHWnd($h_listview) Then
  1066.         Return _SendMessage($h_listview, $LVM_GETUNICODEFORMAT)
  1067.     Else
  1068.         Return GUICtrlSendMsg($h_listview, $LVM_GETUNICODEFORMAT, 0, 0)
  1069.     EndIf
  1070. EndFunc   ;==>_GUICtrlListViewGetUnicodeFormat
  1071.  
  1072. ;===============================================================================
  1073. ;
  1074. ; Description:            _GUICtrlListViewGetView
  1075. ; Parameter(s):        $h_listview - controlID
  1076. ; Requirement:            None
  1077. ; Return Value(s):    Returns a DWORD that specifies the current view
  1078. ; User CallTip:        _GUICtrlListViewGetView($h_listview) Retrieves the current view of a list-view control (required: <GuiListView.au3>)
  1079. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1080. ; Note(s):                Following are the values for views.
  1081. ;                                $LV_VIEW_DETAILS
  1082. ;                                $LV_VIEW_ICON
  1083. ;                                $LV_VIEW_LIST
  1084. ;                                $LV_VIEW_SMALLICON
  1085. ;                                $LV_VIEW_TILE
  1086. ;
  1087. ;===============================================================================
  1088. Func _GUICtrlListViewGetView($h_listview)
  1089.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1090.     If IsHWnd($h_listview) Then
  1091.         Return _SendMessage($h_listview, $LVM_GETVIEW)
  1092.     Else
  1093.         Return GUICtrlSendMsg($h_listview, $LVM_GETVIEW, 0, 0)
  1094.     EndIf
  1095. EndFunc   ;==>_GUICtrlListViewGetView
  1096.  
  1097. ;===============================================================================
  1098. ;
  1099. ; Description:                _GUICtrlListViewHideColumn
  1100. ; Parameter(s):            $h_listview - controlID
  1101. ;                                $i_col - column to hide (set width to zero)
  1102. ; Requirement:                None
  1103. ; Return Value(s):        Returns TRUE if successful, or FALSE otherwise
  1104. ; User CallTip:            _GUICtrlListViewHideColumn($h_listview,$i_col) Hides the column "sets column width to zero" (required: <GuiListView.au3>)
  1105. ; Author(s):                Gary Frost (custompcs at charter dot net)
  1106. ; Note(s):              Idea from Holger
  1107. ;
  1108. ;===============================================================================
  1109. Func _GUICtrlListViewHideColumn($h_listview, $i_col)
  1110.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, False)
  1111.     If IsHWnd($h_listview) Then
  1112.         Return _SendMessage($h_listview, $LVM_SETCOLUMNWIDTH, $i_col)
  1113.     Else
  1114.         Return GUICtrlSendMsg($h_listview, $LVM_SETCOLUMNWIDTH, $i_col, 0)
  1115.     EndIf
  1116. EndFunc   ;==>_GUICtrlListViewHideColumn
  1117.  
  1118. ;===============================================================================
  1119. ;
  1120. ; Description:                _GUICtrlListViewInsertColumn
  1121. ; Parameter(s):            $h_listview - controlID
  1122. ;                                $i_col - Zero based index of column position to insert
  1123. ;                                $s_text - Header Text for column
  1124. ;                                $i_justification - Optional: type of justification for column
  1125. ;                                $i_width - Optional: width of the new column
  1126. ; Requirement:                None
  1127. ; Return Value(s):        Returns TRUE if successful, or FALSE otherwise
  1128. ;                                if error then $LV_ERR is returned
  1129. ; User CallTip:            _GUICtrlListViewInsertColumn($h_listview, $i_col, $s_text[, $i_justification=0[, $i_width=25]]) Inserts a column into a list-view control (required: <GuiListView.au3>)
  1130. ; Author(s):                Gary Frost (custompcs at charter dot net)
  1131. ; Note(s):              $i_justification
  1132. ;                                    0 = Left (default)
  1133. ;                                    1 = Right
  1134. ;                                    2 = Center
  1135. ;
  1136. ;===============================================================================
  1137. Func _GUICtrlListViewInsertColumn($h_listview, $i_col, $s_text, $i_justification = 0, $i_width = 25)
  1138.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, False)
  1139.     Local $struct_LVCOLUMN, $struct_String, $ret
  1140.  
  1141.     $struct_LVCOLUMN = DllStructCreate($LVCOLUMN)
  1142.     If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1143.     $struct_String = DllStructCreate("char[" & StringLen($s_text) + 1 & "]")
  1144.     If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1145.     DllStructSetData($struct_String, 1, $s_text)
  1146.     DllStructSetData($struct_LVCOLUMN, $LVC_MASK, BitOR($LVCF_WIDTH, $LVCF_FMT, $LVCF_TEXT))
  1147.     If ($i_justification == 1) Then
  1148.         DllStructSetData($struct_LVCOLUMN, $LVC_FMT, $LVCFMT_RIGHT)
  1149.     ElseIf ($i_justification == 2) Then
  1150.         DllStructSetData($struct_LVCOLUMN, $LVC_FMT, $LVCFMT_CENTER)
  1151.     Else
  1152.         DllStructSetData($struct_LVCOLUMN, $LVC_FMT, $LVCFMT_LEFT)
  1153.     EndIf
  1154.     DllStructSetData($struct_LVCOLUMN, $LVC_CX, $i_width)
  1155.     
  1156.     If IsHWnd($h_listview) Then
  1157.         Local $sBuffer_pointer = DllStructGetPtr($struct_String)
  1158.         Local $column_struct_pointer = DllStructGetPtr($struct_LVCOLUMN)
  1159.         Local $i_Size = DllStructGetSize($struct_LVCOLUMN)
  1160.         Local $struct_MemMap
  1161.         Local $Memory_pointer = _MemInit ($h_listview, $i_Size + StringLen($s_text) + 1, $struct_MemMap)
  1162.         If @error Then
  1163.             _MemFree ($struct_MemMap)
  1164.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1165.         EndIf
  1166.         Local $string_Memory_pointer = $Memory_pointer + $i_Size
  1167.         DllStructSetData($struct_LVCOLUMN, $LVC_PSZTEXT, $string_Memory_pointer)
  1168.         _MemWrite ($struct_MemMap, $column_struct_pointer)
  1169.         If @error Then
  1170.             _MemFree ($struct_MemMap)
  1171.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1172.         EndIf
  1173.         _MemWrite ($struct_MemMap, $sBuffer_pointer, $string_Memory_pointer, StringLen($s_text) + 1)
  1174.         If @error Then
  1175.             _MemFree ($struct_MemMap)
  1176.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1177.         EndIf
  1178.         $ret = _SendMessage($h_listview, $LVM_INSERTCOLUMNA, $i_col, $Memory_pointer)
  1179.         If @error Then
  1180.             _MemFree ($struct_MemMap)
  1181.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1182.         EndIf
  1183.         _MemFree ($struct_MemMap)
  1184.         If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1185.         Return $ret
  1186.     Else
  1187.         DllStructSetData($struct_LVCOLUMN, $LVC_PSZTEXT, DllStructGetPtr($struct_String))
  1188.         $ret = GUICtrlSendMsg($h_listview, $LVM_INSERTCOLUMNA, $i_col, DllStructGetPtr($struct_LVCOLUMN))
  1189.     EndIf
  1190.     Return $ret
  1191. EndFunc   ;==>_GUICtrlListViewInsertColumn
  1192.  
  1193. ;===============================================================================
  1194. ;
  1195. ; Description:                _GUICtrlListViewInsertItem
  1196. ; Parameter(s):            $h_listview - controlID
  1197. ;                                $i_index - Zero based index of position to insert
  1198. ;                                            if -1 the item will append to the end
  1199. ;                                $s_text - text for the new item
  1200. ; Requirement:                None
  1201. ; Return Value(s):        Returns the index of the new item if successful, or $LV_ERR otherwise
  1202. ; User CallTip:            _GUICtrlListViewInsertItem($h_listview, $i_index, $s_text) Inserts a new item in a list-view control. (required: <GuiListView.au3>)
  1203. ; Author(s):                Gary Frost (custompcs at charter dot net)
  1204. ; Note(s):              $s_text is "|" delimited text
  1205. ;
  1206. ;===============================================================================
  1207. Func _GUICtrlListViewInsertItem($h_listview, $i_index, $s_text)
  1208.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1209.     Local $struct_LVITEM, $struct_String, $ret, $a_text
  1210.  
  1211.     $struct_LVITEM = DllStructCreate($LVITEM)
  1212.     If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1213.     $struct_String = DllStructCreate("char[" & StringLen($s_text) + 1 & "]")
  1214.     If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1215.     $a_text = StringSplit($s_text, "|")
  1216.     DllStructSetData($struct_String, 1, $a_text[1])
  1217.     If $i_index = -1 Then $i_index = _GUICtrlListViewGetItemCount($h_listview)
  1218.     DllStructSetData($struct_LVITEM, $LVI_MASK, $LVIF_TEXT)
  1219.     DllStructSetData($struct_LVITEM, $LVI_IITEM, $i_index)
  1220.     DllStructSetData($struct_LVITEM, $LVI_CCHTEXTMAX, StringLen($s_text) + 1)
  1221. ;~     DllStructSetData($struct_LVITEM  , $LVI_IIMAGE    , -1  )
  1222. ;~     DllStructSetData($struct_LVITEM  , $LVI_LPARAM    , 0 )
  1223. ;~     DllStructSetData($struct_LVITEM  , $LVI_IINDENT   , 0 )
  1224.     If IsHWnd($h_listview) Then
  1225.         Local $sBuffer_pointer = DllStructGetPtr($struct_String)
  1226.         Local $LVITEM_pointer = DllStructGetPtr($struct_LVITEM)
  1227.         Local $i_Size = DllStructGetSize($struct_LVITEM)
  1228.         Local $struct_MemMap
  1229.         Local $Memory_pointer = _MemInit ($h_listview, $i_Size + StringLen($s_text) + 1, $struct_MemMap)
  1230.         If @error Then
  1231.             _MemFree ($struct_MemMap)
  1232.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1233.         EndIf
  1234.         Local $string_Memory_pointer = $Memory_pointer + $i_Size
  1235.         DllStructSetData($struct_LVITEM, $LVI_PSZTEXT, $string_Memory_pointer)
  1236.         _MemWrite ($struct_MemMap, $LVITEM_pointer)
  1237.         If @error Then
  1238.             _MemFree ($struct_MemMap)
  1239.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1240.         EndIf
  1241.         _MemWrite ($struct_MemMap, $sBuffer_pointer, $string_Memory_pointer, StringLen($s_text) + 1)
  1242.         If @error Then
  1243.             _MemFree ($struct_MemMap)
  1244.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1245.         EndIf
  1246.         $ret = _SendMessage($h_listview, $LVM_INSERTITEMA, 0, $Memory_pointer)
  1247.         If @error Then
  1248.             _MemFree ($struct_MemMap)
  1249.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1250.         EndIf
  1251.         _MemFree ($struct_MemMap)
  1252.         If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1253.     Else
  1254.         DllStructSetData($struct_LVITEM, $LVI_PSZTEXT, DllStructGetPtr($struct_String))
  1255.         $ret = GUICtrlSendMsg($h_listview, $LVM_INSERTITEMA, 0, DllStructGetPtr($struct_LVITEM))
  1256.     EndIf
  1257.     Local $i
  1258.     For $i = 2 To $a_text[0]
  1259.         _GUICtrlListViewSetItemText($h_listview, $i_index, $i - 1, $a_text[$i])
  1260.     Next
  1261.     Return $ret
  1262. EndFunc   ;==>_GUICtrlListViewInsertItem
  1263.  
  1264. ;===============================================================================
  1265. ;
  1266. ; Description:                _GUICtrlListViewJustifyColumn
  1267. ; Parameter(s):            $h_listview - controlID
  1268. ;                                $i_col - Zero based index of column Justify
  1269. ;                                $i_justification - Optional: type of justification for column
  1270. ; Requirement:                None
  1271. ; Return Value(s):        Returns TRUE if successful, or FALSE otherwise
  1272. ;                                if error then $LV_ERR is returned
  1273. ; User CallTip:            _GUICtrlListViewJustifyColumn($h_listview, $i_col[, $i_justification=0]) Set Justification of a column for a list-view control (required: <GuiListView.au3>)
  1274. ; Author(s):                Gary Frost (custompcs at charter dot net)
  1275. ; Note(s):              $i_justification
  1276. ;                                    0 = Left (default)
  1277. ;                                    1 = Right
  1278. ;                                    2 = Center
  1279. ;
  1280. ;===============================================================================
  1281. Func _GUICtrlListViewJustifyColumn($h_listview, $i_col, $i_justification = 0)
  1282.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, False)
  1283.     Local $struct_LVCOLUMN, $ret
  1284.  
  1285.     $struct_LVCOLUMN = DllStructCreate($LVCOLUMN)
  1286.     If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1287.     DllStructSetData($struct_LVCOLUMN, $LVC_MASK, $LVCF_FMT)
  1288.     If ($i_justification == 1) Then
  1289.         DllStructSetData($struct_LVCOLUMN, $LVC_FMT, $LVCFMT_RIGHT)
  1290.     ElseIf ($i_justification == 2) Then
  1291.         DllStructSetData($struct_LVCOLUMN, $LVC_FMT, $LVCFMT_CENTER)
  1292.     Else
  1293.         DllStructSetData($struct_LVCOLUMN, $LVC_FMT, $LVCFMT_LEFT)
  1294.     EndIf
  1295.     If IsHWnd($h_listview) Then
  1296.         Local $column_struct_pointer = DllStructGetPtr($struct_LVCOLUMN)
  1297.         Local $i_Size = DllStructGetSize($struct_LVCOLUMN)
  1298.         Local $struct_MemMap
  1299.         Local $Memory_pointer = _MemInit ($h_listview, $i_Size, $struct_MemMap)
  1300.         If @error Then
  1301.             _MemFree ($struct_MemMap)
  1302.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1303.         EndIf
  1304.         _MemWrite ($struct_MemMap, $column_struct_pointer)
  1305.         If @error Then
  1306.             _MemFree ($struct_MemMap)
  1307.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1308.         EndIf
  1309.         $ret = _SendMessage($h_listview, $LVM_SETCOLUMNA, $i_col, $Memory_pointer)
  1310.         If @error Then
  1311.             _MemFree ($struct_MemMap)
  1312.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1313.         EndIf
  1314.         _MemFree ($struct_MemMap)
  1315.         If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1316.     Else
  1317.         $ret = GUICtrlSendMsg($h_listview, $LVM_SETCOLUMNA, $i_col, DllStructGetPtr($struct_LVCOLUMN))
  1318.     EndIf
  1319.     Return $ret
  1320. EndFunc   ;==>_GUICtrlListViewJustifyColumn
  1321.  
  1322. ;===============================================================================
  1323. ;
  1324. ; Description:            _GUICtrlListViewScroll
  1325. ; Parameter(s):        $h_listview - controlID
  1326. ;                            $i_dx - Value of type int that specifies the amount of horizontal scrolling in pixels.
  1327. ;                                      If the list-view control is in list-view, this value specifies the number of columns to scroll
  1328. ;                            $i_dy - Value of type int that specifies the amount of vertical scrolling in pixels
  1329. ; Requirement:            None
  1330. ; Return Value(s):    Returns TRUE if successful, or FALSE otherwise
  1331. ; User CallTip:        _GUICtrlListViewScroll($h_listview, $i_dx, $i_dy) Scrolls the content of a list-view control (required: <GuiListView.au3>)
  1332. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1333. ; Note(s):                When the list-view control is in report view, the control can
  1334. ;                            only be scrolled vertically in whole line increments.
  1335. ;
  1336. ;                            Therefore, the $i_dy parameter will be rounded to the nearest number
  1337. ;                            of pixels that form a whole line increment.
  1338. ;
  1339. ;                            For example, if the height of a line is 16 pixels and 8 is passed for $i_dy,
  1340. ;                            the list will be scrolled by 16 pixels (1 line). If 7 is passed for $i_dy,
  1341. ;                            the list will be scrolled 0 pixels (0 lines).
  1342. ;
  1343. ;===============================================================================
  1344. Func _GUICtrlListViewScroll($h_listview, $i_dx, $i_dy)
  1345.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, False)
  1346.     If IsHWnd($h_listview) Then
  1347.         Return _SendMessage($h_listview, $LVM_SCROLL, $i_dx, $i_dy)
  1348.     Else
  1349.         Return GUICtrlSendMsg($h_listview, $LVM_SCROLL, $i_dx, $i_dy)
  1350.     EndIf
  1351. EndFunc   ;==>_GUICtrlListViewScroll
  1352.  
  1353. ;===============================================================================
  1354. ;
  1355. ; Description:            _GUICtrlListViewSetCheckState
  1356. ; Parameter(s):        $h_listview - controlID
  1357. ;                            $i_index - Zero-based index of the item
  1358. ;                            $i_check - Optional: value to set checked state to (1 = checked, 0 = not checked)
  1359. ; Requirement:            None.
  1360. ; Return Value(s):    Returns TRUE if successful, or FALSE otherwise
  1361. ;                            If error then $LV_ERR is returned
  1362. ; User CallTip:        _GUICtrlListViewSetCheckState($h_listview, $i_index[, $i_check = 1]) Sets the checked state of a list-view control item (required: <GuiListView.au3>)
  1363. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1364. ; Note(s):                $i_index = -1 sets all items
  1365. ;                            $i_check = 1 (default)
  1366. ;
  1367. ;===============================================================================
  1368. Func _GUICtrlListViewSetCheckState($h_listview, $i_index, $i_check = 1)
  1369.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, False)
  1370.     Local $ret
  1371.     Local $struct_LVITEM = DllStructCreate($LVITEM)
  1372.     If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1373.     DllStructSetData($struct_LVITEM, $LVI_MASK, $LVIF_STATE)
  1374.     DllStructSetData($struct_LVITEM, $LVI_IITEM, $i_index)
  1375.     If ($i_check) Then
  1376.         DllStructSetData($struct_LVITEM, $LVI_STATE, 0x2000)
  1377.     Else
  1378.         DllStructSetData($struct_LVITEM, $LVI_STATE, 0x1000)
  1379.     EndIf
  1380.     DllStructSetData($struct_LVITEM, $LVI_STATEMASK, $LVIS_STATEIMAGEMASK)
  1381.     If IsHWnd($h_listview) Then
  1382.         Local $LVITEM_pointer = DllStructGetPtr($struct_LVITEM)
  1383.         Local $i_Size = DllStructGetSize($struct_LVITEM)
  1384.         Local $struct_MemMap
  1385.         Local $Memory_pointer = _MemInit ($h_listview, $i_Size + 4096, $struct_MemMap)
  1386.         If @error Then
  1387.             _MemFree ($struct_MemMap)
  1388.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1389.         EndIf
  1390.         _MemWrite ($struct_MemMap, $LVITEM_pointer)
  1391.         If @error Then
  1392.             _MemFree ($struct_MemMap)
  1393.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1394.         EndIf
  1395.         $ret = _SendMessage($h_listview, $LVM_SETITEMSTATE, $i_index, $Memory_pointer)
  1396.         If @error Then
  1397.             _MemFree ($struct_MemMap)
  1398.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1399.         EndIf
  1400.         _MemFree ($struct_MemMap)
  1401.         If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1402.     Else
  1403.         $ret = GUICtrlSendMsg($h_listview, $LVM_SETITEMSTATE, $i_index, DllStructGetPtr($struct_LVITEM))
  1404.     EndIf
  1405.     Return $ret
  1406. EndFunc   ;==>_GUICtrlListViewSetCheckState
  1407.  
  1408. ;===============================================================================
  1409. ;
  1410. ; Description:                _GUICtrlListViewSetColumnHeaderText
  1411. ; Parameter(s):            $h_listview - controlID
  1412. ;                                $i_col - Zero based index of column Justify
  1413. ;                                $s_text - New text for column header
  1414. ; Requirement:                None
  1415. ; Return Value(s):        Returns TRUE if successful, or FALSE otherwise
  1416. ;                                if error then $LV_ERR is returned
  1417. ; User CallTip:            _GUICtrlListViewSetColumnHeaderText($h_listview, $i_col, $s_text) Change the text of a column header for a list-view control (required: <GuiListView.au3>)
  1418. ; Author(s):                Gary Frost (custompcs at charter dot net)
  1419. ; Note(s):
  1420. ;
  1421. ;===============================================================================
  1422. Func _GUICtrlListViewSetColumnHeaderText($h_listview, $i_col, $s_text)
  1423.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, False)
  1424.     Local $struct_LVCOLUMN, $ret, $struct_String
  1425.  
  1426.     $struct_String = DllStructCreate("char[" & StringLen($s_text) + 1 & "]")
  1427.     If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1428.     DllStructSetData($struct_String, 1, $s_text)
  1429.     $struct_LVCOLUMN = DllStructCreate($LVCOLUMN)
  1430.     If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1431.     DllStructSetData($struct_LVCOLUMN, $LVC_MASK, $LVCF_TEXT)
  1432.     If IsHWnd($h_listview) Then
  1433.         Local $sBuffer_pointer = DllStructGetPtr($struct_String)
  1434.         Local $column_struct_pointer = DllStructGetPtr($struct_LVCOLUMN)
  1435.         Local $i_Size = DllStructGetSize($struct_LVCOLUMN)
  1436.         Local $struct_MemMap
  1437.         Local $Memory_pointer = _MemInit ($h_listview, $i_Size + StringLen($s_text) + 1, $struct_MemMap)
  1438.         If @error Then
  1439.             _MemFree ($struct_MemMap)
  1440.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1441.         EndIf
  1442.         Local $string_Memory_pointer = $Memory_pointer + $i_Size
  1443.         DllStructSetData($struct_LVCOLUMN, $LVC_PSZTEXT, $string_Memory_pointer)
  1444.         _MemWrite ($struct_MemMap, $column_struct_pointer)
  1445.         If @error Then
  1446.             _MemFree ($struct_MemMap)
  1447.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1448.         EndIf
  1449.         _MemWrite ($struct_MemMap, $sBuffer_pointer, $string_Memory_pointer, StringLen($s_text) + 1)
  1450.         If @error Then
  1451.             _MemFree ($struct_MemMap)
  1452.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1453.         EndIf
  1454.         $ret = _SendMessage($h_listview, $LVM_SETCOLUMNA, $i_col, $Memory_pointer)
  1455.         If @error Then
  1456.             _MemFree ($struct_MemMap)
  1457.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1458.         EndIf
  1459.         _MemFree ($struct_MemMap)
  1460.         If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1461.     Else
  1462.         DllStructSetData($struct_LVCOLUMN, $LVC_PSZTEXT, DllStructGetPtr($struct_String))
  1463.         $ret = GUICtrlSendMsg($h_listview, $LVM_SETCOLUMNA, $i_col, DllStructGetPtr($struct_LVCOLUMN))
  1464.     EndIf
  1465.     Return $ret
  1466. EndFunc   ;==>_GUICtrlListViewSetColumnHeaderText
  1467.  
  1468. ;===============================================================================
  1469. ;
  1470. ; Description:            _GUICtrlListViewSetColumnOrder
  1471. ; Parameter(s):        $h_listview - controlID
  1472. ;                            $s_order - "|" delimited column order .i.e "2|0|3|1"
  1473. ; Requirement:            None
  1474. ; Return Value(s):    Returns nonzero if successful, or zero otherwise.
  1475. ;                            If an error occurs, the return value is $LV_ERR.
  1476. ; User CallTip:        _GUICtrlListViewSetColumnOrder($h_listview, $s_order) Sets the left-to-right order of columns in a list-view control. (required: <GuiListView.au3>)
  1477. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1478. ; Note(s):           Columns are zero-based
  1479. ;
  1480. ;===============================================================================
  1481. Func _GUICtrlListViewSetColumnOrder($h_listview, $s_order)
  1482.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1483.     Local $i, $ret
  1484.     Local $struct = ""
  1485.     Local $a_order = StringSplit($s_order, "|")
  1486.     If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1487.     For $i = 1 To $a_order[0]
  1488.         $struct &= "int;"
  1489.     Next
  1490.     $struct = StringTrimRight($struct, 1)
  1491.     Local $struct_LVCOLUMN = DllStructCreate($struct)
  1492.     For $i = 1 To $a_order[0]
  1493.         DllStructSetData($struct_LVCOLUMN, $i, $a_order[$i])
  1494.     Next
  1495.     If IsHWnd($h_listview) Then
  1496.         Local $sBuffer_pointer = DllStructGetPtr($struct_LVCOLUMN)
  1497.         Local $i_Size = DllStructGetSize($struct_LVCOLUMN)
  1498.         Local $struct_MemMap
  1499.         Local $Memory_pointer = _MemInit ($h_listview, $i_Size, $struct_MemMap)
  1500.         If @error Then
  1501.             _MemFree ($struct_MemMap)
  1502.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1503.         EndIf
  1504.         _MemWrite ($struct_MemMap, $sBuffer_pointer)
  1505.         If @error Then
  1506.             _MemFree ($struct_MemMap)
  1507.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1508.         EndIf
  1509.         $ret = _SendMessage($h_listview, $LVM_SETCOLUMNORDERARRAY, $a_order[0], $Memory_pointer)
  1510.         If @error Then
  1511.             _MemFree ($struct_MemMap)
  1512.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1513.         EndIf
  1514.         _MemFree ($struct_MemMap)
  1515.         If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1516.     Else
  1517.         $ret = GUICtrlSendMsg($h_listview, $LVM_SETCOLUMNORDERARRAY, $a_order[0], DllStructGetPtr($struct_LVCOLUMN))
  1518.     EndIf
  1519.     If (Not $ret) Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1520.     Return $ret
  1521. EndFunc   ;==>_GUICtrlListViewSetColumnOrder
  1522.  
  1523. ;===============================================================================
  1524. ;
  1525. ; Description:            _GUICtrlListViewSetColumnWidth
  1526. ; Parameter(s):        $h_listview - controlID
  1527. ;                            $i_col - Zero-based index of a valid column. For list-view mode, this parameter must be set to zero
  1528. ;                            $i_width - New width of the column, in pixels.
  1529. ; Requirement:            None
  1530. ; Return Value(s):    Returns TRUE if successful, or FALSE otherwise
  1531. ; User CallTip:        _GUICtrlListViewSetColumnWidth($h_listview, $i_col, $i_width) Changes the width of a column (required: <GuiListView.au3>)
  1532. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1533. ; Note(s):                For list-view mode, this parameter must be set to zero
  1534. ;
  1535. ;                            $i_width
  1536. ;                                New width of the column, in pixels. For report-view mode, the following special values are supported:
  1537. ;                                    $LVSCW_AUTOSIZE
  1538. ;                                        Automatically sizes the column.
  1539. ;                                    $LVSCW_AUTOSIZE_USEHEADER
  1540. ;                                        Automatically sizes the column to fit the header text.
  1541. ;                                        If you use this value with the last column, its width
  1542. ;                                        is set to fill the remaining width of the list-view control
  1543. ;
  1544. ;===============================================================================
  1545. Func _GUICtrlListViewSetColumnWidth($h_listview, $i_col, $i_width)
  1546.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, False)
  1547.     If IsHWnd($h_listview) Then
  1548.         Return _SendMessage($h_listview, $LVM_SETCOLUMNWIDTH, $i_col, $i_width)
  1549.     Else
  1550.         Return GUICtrlSendMsg($h_listview, $LVM_SETCOLUMNWIDTH, $i_col, $i_width)
  1551.     EndIf
  1552. EndFunc   ;==>_GUICtrlListViewSetColumnWidth
  1553.  
  1554. ;===============================================================================
  1555. ;
  1556. ; Description:            _GUICtrlListViewSetHotItem
  1557. ; Parameter(s):        $h_listview - controlID
  1558. ;                            $i_index - Zero-based index of the item to be set as the hot item
  1559. ; Requirement:            None
  1560. ; Return Value(s):    Returns the index of the item that was previously hot
  1561. ;                            $LV_ERR is returned if no item previously hot
  1562. ; User CallTip:        _GUICtrlListViewSetHotItem($h_listview, $i_index) Sets the hot item for a list-view control (required: <GuiListView.au3>)
  1563. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1564. ; Note(s):                :
  1565. ;
  1566. ;===============================================================================
  1567. Func _GUICtrlListViewSetHotItem($h_listview, $i_index)
  1568.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1569.     If IsHWnd($h_listview) Then
  1570.         Return _SendMessage($h_listview, $LVM_SETHOTITEM, $i_index)
  1571.     Else
  1572.         Return GUICtrlSendMsg($h_listview, $LVM_SETHOTITEM, $i_index, 0)
  1573.     EndIf
  1574. EndFunc   ;==>_GUICtrlListViewSetHotItem
  1575.  
  1576. ;===============================================================================
  1577. ;
  1578. ; Description:            _GUICtrlListViewSetHoverTime
  1579. ; Parameter(s):        $h_listview - controlID
  1580. ;                            $i_time - The new amount of time, in milliseconds
  1581. ; Requirement:            None
  1582. ; Return Value(s):    Returns the previous hover time
  1583. ; User CallTip:        _GUICtrlListViewSetHoverTime($h_listview, $i_time) Sets the amount of time which the mouse cursor must hover over an item before it is selected (required: <GuiListView.au3>)
  1584. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1585. ; Note(s):                $i_time
  1586. ;                                If this value is -1, then the hover time is set to the default hover time
  1587. ;
  1588. ;                            The hover time only affects list-view controls that have the
  1589. ;                            LVS_EX_TRACKSELECT, LVS_EX_ONECLICKACTIVATE, or
  1590. ;                            LVS_EX_TWOCLICKACTIVATE extended list-view style
  1591. ;
  1592. ;===============================================================================
  1593. Func _GUICtrlListViewSetHoverTime($h_listview, $i_time)
  1594.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1595.     If IsHWnd($h_listview) Then
  1596.         Return _SendMessage($h_listview, $LVM_SETHOVERTIME, 0, $i_time)
  1597.     Else
  1598.         Return GUICtrlSendMsg($h_listview, $LVM_SETHOVERTIME, 0, $i_time)
  1599.     EndIf
  1600. EndFunc   ;==>_GUICtrlListViewSetHoverTime
  1601.  
  1602. ;===============================================================================
  1603. ;
  1604. ; Description:            _GUICtrlListViewSetItemCount
  1605. ; Parameter(s):        $h_listview - controlID
  1606. ;                            $i_items - Number of items that the list-view control will ultimately contain.
  1607. ; Requirement:            None
  1608. ; Return Value(s):    Returns nonzero if successful, or zero otherwise.
  1609. ; User CallTip:        _GuiCtrlListViewSetItemCount($h_listview, $i_items) Causes the list-view control to allocate memory for the specified number of items. (required: <GuiListView.au3>)
  1610. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1611. ; Note(s):                Causes the control to allocate its internal data structures for the specified number of items.
  1612. ;                            This prevents the control from having to allocate the data structures every time an item is added.
  1613. ;
  1614. ;===============================================================================
  1615. Func _GUICtrlListViewSetItemCount($h_listview, $i_items)
  1616.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, 0)
  1617.     If IsHWnd($h_listview) Then
  1618.         Return _SendMessage($h_listview, $LVM_SETITEMCOUNT, $i_items, BitOR($LVSICF_NOINVALIDATEALL, $LVSICF_NOSCROLL))
  1619.     Else
  1620.         Return GUICtrlSendMsg($h_listview, $LVM_SETITEMCOUNT, $i_items, BitOR($LVSICF_NOINVALIDATEALL, $LVSICF_NOSCROLL))
  1621.     EndIf
  1622. EndFunc   ;==>_GUICtrlListViewSetItemCount
  1623.  
  1624. ;===============================================================================
  1625. ;
  1626. ; Description:            _GUICtrlListViewSetItemSelState
  1627. ; Parameter(s):        $h_listview - controlID
  1628. ;                            $i_index - Zero based index of the item
  1629. ;                            $i_selected - Optional: set the state of the item (1 = selected, 0 = not selected)
  1630. ;                    $i_focused - Optional: set the state of the item (1 = focused, 0 = not focused) (default = 0)
  1631. ; Requirement:            None
  1632. ; Return Value(s):    1 if successful, 0 otherwise
  1633. ;                            If error then $LV_ERR is returned
  1634. ; User CallTip:        _GUICtrlListViewSetItemSelState($h_listview, $i_index[, $i_selected = 1[, $i_focused = 0]]) Sets the Item Selected/UnSelected (required: <GuiListView.au3>)
  1635. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1636. ; Note(s):                $i_index = -1 sets all items for MultiSelect ListView
  1637. ;
  1638. ;===============================================================================
  1639. Func _GUICtrlListViewSetItemSelState($h_listview, $i_index, $i_selected = 1, $i_focused = 0)
  1640.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1641.     Local $ret
  1642.     Local $struct_LVITEM = DllStructCreate($LVITEM)
  1643.     If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1644.     If ($i_selected == 1) Then
  1645.         $i_selected = $LVNI_SELECTED
  1646.     Else
  1647.         $i_selected = 0
  1648.     EndIf
  1649.     If ($i_focused == 1) Then
  1650.         $i_focused = $LVNI_FOCUSED
  1651.     Else
  1652.         $i_focused = 0
  1653.     EndIf
  1654.     DllStructSetData($struct_LVITEM, $LVI_MASK, $LVIF_STATE)
  1655.     DllStructSetData($struct_LVITEM, $LVI_IITEM, $i_index)
  1656.     DllStructSetData($struct_LVITEM, $LVI_STATE, BitOR($i_selected, $i_focused))
  1657.     DllStructSetData($struct_LVITEM, $LVI_STATEMASK, BitOR($LVIS_SELECTED, $i_focused))
  1658.     If IsHWnd($h_listview) Then
  1659.         Local $sBuffer_pointer = DllStructGetPtr($struct_LVITEM)
  1660.         Local $i_Size = DllStructGetSize($struct_LVITEM)
  1661.         Local $struct_MemMap
  1662.         Local $Memory_pointer = _MemInit ($h_listview, $i_Size, $struct_MemMap)
  1663.         If @error Then
  1664.             _MemFree ($struct_MemMap)
  1665.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1666.         EndIf
  1667.         _MemWrite ($struct_MemMap, $sBuffer_pointer)
  1668.         If @error Then
  1669.             _MemFree ($struct_MemMap)
  1670.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1671.         EndIf
  1672.         $ret = _SendMessage($h_listview, $LVM_SETITEMSTATE, $i_index, $Memory_pointer)
  1673.         If @error Then
  1674.             _MemFree ($struct_MemMap)
  1675.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1676.         EndIf
  1677.         _MemFree ($struct_MemMap)
  1678.         If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1679.     Else
  1680.         $ret = GUICtrlSendMsg($h_listview, $LVM_SETITEMSTATE, $i_index, DllStructGetPtr($struct_LVITEM))
  1681.     EndIf
  1682.     Return $ret
  1683. EndFunc   ;==>_GUICtrlListViewSetItemSelState
  1684.  
  1685. ;===============================================================================
  1686. ;
  1687. ; Description:            _GUICtrlListViewSetItemText
  1688. ; Parameter(s):        $h_listview - controlID
  1689. ;                            $i_index - Zero based index of the item
  1690. ;                            $i_subitem - Index of the subitem, or it can be zero to set the item label.
  1691. ;                            $s_text - String containing the new text
  1692. ; Requirement:            None
  1693. ; Return Value(s):    1 if successful, 0 if not
  1694. ;                            If error then $LV_ERR is returned
  1695. ; User CallTip:        _GUICtrlListViewSetItemText($h_listview, $i_index, $i_subitem, $s_text) Changes the text of a list-view item or subitem. (required: <GuiListView.au3>)
  1696. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1697. ; Note(s):
  1698. ;
  1699. ;===============================================================================
  1700. Func _GUICtrlListViewSetItemText($h_listview, $i_index, $i_SubItem, $s_text)
  1701.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1702.     Local $ret
  1703.     Local $struct_LVITEM = DllStructCreate($LVITEM)
  1704.     If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1705.     Local $struct_String = DllStructCreate("char[" & StringLen($s_text) + 1 & "]")
  1706.     If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1707.     DllStructSetData($struct_String, 1, $s_text)
  1708.     DllStructSetData($struct_LVITEM, $LVI_MASK, $LVIF_TEXT)
  1709.     DllStructSetData($struct_LVITEM, $LVI_IITEM, $i_index)
  1710.     DllStructSetData($struct_LVITEM, $LVI_ISUBITEM, $i_SubItem)
  1711.     If IsHWnd($h_listview) Then
  1712.         Local $sBuffer_pointer = DllStructGetPtr($struct_String)
  1713.         Local $LVITEM_pointer = DllStructGetPtr($struct_LVITEM)
  1714.         Local $i_Size = DllStructGetSize($struct_LVITEM)
  1715.         Local $struct_MemMap
  1716.         Local $Memory_pointer = _MemInit ($h_listview, $i_Size + StringLen($s_text) + 1, $struct_MemMap)
  1717.         If @error Then
  1718.             _MemFree ($struct_MemMap)
  1719.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1720.         EndIf
  1721.         Local $string_Memory_pointer = $Memory_pointer + $i_Size
  1722.         DllStructSetData($struct_LVITEM, $LVI_PSZTEXT, $string_Memory_pointer)
  1723.         If @error Then
  1724.             _MemFree ($struct_MemMap)
  1725.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1726.         EndIf
  1727.         _MemWrite ($struct_MemMap, $LVITEM_pointer)
  1728.         If @error Then
  1729.             _MemFree ($struct_MemMap)
  1730.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1731.         EndIf
  1732.         _MemWrite ($struct_MemMap, $sBuffer_pointer, $string_Memory_pointer, StringLen($s_text) + 1)
  1733.         If @error Then
  1734.             _MemFree ($struct_MemMap)
  1735.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1736.         EndIf
  1737.         $ret = _SendMessage($h_listview, $LVM_SETITEMTEXTA, 0, $Memory_pointer)
  1738.         If @error Then
  1739.             _MemFree ($struct_MemMap)
  1740.             Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1741.         EndIf
  1742.         _MemFree ($struct_MemMap)
  1743.         If @error Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1744.     Else
  1745.         DllStructSetData($struct_LVITEM, $LVI_PSZTEXT, DllStructGetPtr($struct_String))
  1746.         $ret = GUICtrlSendMsg($h_listview, $LVM_SETITEMTEXTA, $i_index, DllStructGetPtr($struct_LVITEM))
  1747.     EndIf
  1748.     Return $ret
  1749. EndFunc   ;==>_GUICtrlListViewSetItemText
  1750.  
  1751. ;===============================================================================
  1752. ;
  1753. ; Description:            _GUICtrlListViewSetSelectedColumn
  1754. ; Parameter(s):        $h_listview - controlID
  1755. ;                            $i_col - Value of type int that specifies the column index
  1756. ; Requirement:            None
  1757. ; Return Value(s):    Returns TRUE if successful, or FALSE otherwise
  1758. ; User CallTip:        _GUICtrlListViewSetSelectedColumn($h_listview, $i_col) Sets the index of the selected column (required: <GuiListView.au3>)
  1759. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1760. ; Note(s):                The column indices are stored in an int array
  1761. ;
  1762. ;===============================================================================
  1763. Func _GUICtrlListViewSetSelectedColumn($h_listview, $i_col)
  1764.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, False)
  1765.     If IsHWnd($h_listview) Then
  1766.         Return _SendMessage($h_listview, $LVM_SETSELECTEDCOLUMN, $i_col)
  1767.     Else
  1768.         Return GUICtrlSendMsg($h_listview, $LVM_SETSELECTEDCOLUMN, $i_col, 0)
  1769.     EndIf
  1770. EndFunc   ;==>_GUICtrlListViewSetSelectedColumn
  1771.  
  1772. ;===============================================================================
  1773. ;
  1774. ; Description:            _GUICtrlListViewSort
  1775. ; Parameter(s):        $h_listview - controlID
  1776. ;                       $v_descending    - boolean value, can be a single value or array
  1777. ;                       $i_sortcol        - column to sort on
  1778. ; Requirement:            Array.au3
  1779. ; Return Value(s):    None
  1780. ; User CallTip:        _GUICtrlListViewSort(ByRef $h_listview, ByRef $v_descending, $i_sortcol) Sorts a list-view control (required: <GuiListView.au3>)
  1781. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1782. ; Note(s):                :
  1783. ;
  1784. ;===============================================================================
  1785. Func _GUICtrlListViewSort($h_listview, ByRef $v_descending, $i_sortcol)
  1786.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, 0)
  1787.     Local $X, $Y, $Z, $b_desc, $columns, $items, $v_item, $temp_item
  1788.     If _GUICtrlListViewGetItemCount($h_listview) Then
  1789.         If (IsArray($v_descending)) Then
  1790.             $b_desc = $v_descending[$i_sortcol]
  1791.         Else
  1792.             $b_desc = $v_descending
  1793.         EndIf
  1794.         $columns = _GUICtrlListViewGetSubItemsCount($h_listview)
  1795.         $items = _GUICtrlListViewGetItemCount($h_listview)
  1796.         For $X = 1 To $columns
  1797.             $temp_item = $temp_item & " |"
  1798.         Next
  1799.         $temp_item = StringTrimRight($temp_item, 1)
  1800.         Local $a_lv[$items][$columns + 1], $i_selected
  1801.         $i_selected = StringSplit(_GUICtrlListViewGetSelectedIndices($h_listview), "|")
  1802.         For $X = 0 To UBound($a_lv) - 1 Step 1
  1803.             For $Y = 0 To UBound($a_lv, 2) - 2 Step 1
  1804.                 $v_item = StringStripWS(_GUICtrlListViewGetItemText($h_listview, $X, $Y), 2)
  1805.                 If (StringIsFloat($v_item) Or StringIsInt($v_item)) Then
  1806.                     $a_lv[$X][$Y] = Number($v_item)
  1807.                 Else
  1808.                     $a_lv[$X][$Y] = $v_item
  1809.                 EndIf
  1810.             Next
  1811.             $a_lv[$X][$Y] = $X
  1812.         Next
  1813.         _ArraySort($a_lv, $b_desc, 0, 0, $columns + 1, $i_sortcol)
  1814.         _GUICtrlListViewSetItemSelState($h_listview, -1, 0)
  1815.         For $X = 0 To UBound($a_lv) - 1 Step 1
  1816.             For $Y = 0 To UBound($a_lv, 2) - 2 Step 1
  1817.                 _GUICtrlListViewSetItemText($h_listview, $X, $Y, $a_lv[$X][$Y])
  1818.             Next
  1819.             For $Z = 1 To $i_selected[0]
  1820.                 If $a_lv[$X][UBound($a_lv, 2) - 1] = $i_selected[$Z]Then
  1821.                     _GUICtrlListViewSetItemSelState($h_listview, $X, 1, 1)
  1822.                     ExitLoop
  1823.                 EndIf
  1824.             Next
  1825.         Next
  1826.         If (IsArray($v_descending)) Then
  1827.             $v_descending[$i_sortcol] = Not $b_desc
  1828.         Else
  1829.             $v_descending = Not $b_desc
  1830.         EndIf
  1831.     EndIf
  1832. EndFunc   ;==>_GUICtrlListViewSort
  1833.  
  1834. ;===============================================================================
  1835. ; the following functions are for internal use or possibly new functions as
  1836. ; of yet not released
  1837. ;===============================================================================
  1838.  
  1839. ;===============================================================================
  1840. ;
  1841. ; Description:            _ReverseColorOrder
  1842. ; Parameter(s):        $v_color - Hex Color
  1843. ; Requirement:            None
  1844. ; Return Value(s):    Return Hex RGB or BGR Color
  1845. ; User CallTip:        _ReverseColorOder($v_color) Convert Hex RGB or BGR Color to Hex RGB or BGR Color
  1846. ; Author(s):            Gary Frost (custompcs at charter dot net)
  1847. ; Note(s):                Used for getting List view colors
  1848. ;
  1849. ;===============================================================================
  1850. Func _ReverseColorOrder($v_color)
  1851.     Local $tc = Hex(String($v_color), 6)
  1852.     Return '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2)
  1853. EndFunc   ;==>_ReverseColorOrder
  1854.  
  1855. ;===============================================================================
  1856. ; ====================================================================================================
  1857. ; Description ..: Arranges items in icon view
  1858. ; Parameters ...: $h_listview        - Handle to control
  1859. ;                 $i_arrange        - Alignment. This can be one of the following values:
  1860. ;                   $LVA_ALIGNLEFT  - Aligns items along the left edge of the window
  1861. ;                   $LVA_ALIGNTOP   - Aligns items along the top edge of the window
  1862. ;                   $LVA_DEFAULT    - Aligns items according to the listview controls current alignment
  1863. ;                     styles (the default value).
  1864. ;                   $LVA_SNAPTOGRID - Snaps all icons to the nearest grid position.
  1865. ; Return values : Success - True
  1866. ;                 Failure - False
  1867. ; ====================================================================================================
  1868. ;===============================================================================
  1869. Func _GUICtrlListViewArrange($h_listview, $i_arrange)
  1870.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, False)
  1871.     If $i_arrange <> $LVA_ALIGNLEFT And $i_arrange <> $LVA_ALIGNTOP And _
  1872.             $i_arrange <> $LVA_DEFAULT And $i_arrange <> $LVA_SNAPTOGRID Then Return SetError(-1, -1, 0)
  1873.     If IsHWnd($h_listview) Then
  1874.         Return _SendMessage($h_listview, $LVM_ARRANGE, $i_arrange)
  1875.     Else
  1876.         Return GUICtrlSendMsg($h_listview, $LVM_ARRANGE, $i_arrange, 0)
  1877.     EndIf
  1878. EndFunc   ;==>_GUICtrlListViewArrange
  1879.  
  1880. ; ====================================================================================================
  1881. ; Description ..: Sets the spacing between icons in listview controls that have the LVS_ICON style
  1882. ; Parameters ...: $h_listview        - Handle to control
  1883. ;                 $i_cx          - Distance, in pixels, to set between icons on the x-axis
  1884. ;                 $i_cy          - Distance, in pixels, to set between icons on the y-axis
  1885. ; Return values : Returns a DWORD value that contains the previous cx in the low word and the previous
  1886. ;                 cy in the high word.
  1887. ; Notes ........: Values for cx and cy are relative to the upper-left corner of an icon bitmap. To set
  1888. ;                 spacing between icons that do not overlap, the cx or cy values must include the size
  1889. ;                 of the icon, plus the amount of empty space desired between icons.   Values that  do
  1890. ;                 not include the width of the icon will result in overlaps.
  1891. ; ====================================================================================================
  1892. Func _GUICtrlListViewSetIconSpacing($h_listview, $i_cx, $i_cy)
  1893.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR)
  1894.     If IsHWnd($h_listview) Then
  1895. ;~         Return _SendMessage ($h_listview, $LVM_SETICONSPACING, 0, $i_cx * 65536 + $i_cy)
  1896.         Return _SendMessage($h_listview, $LVM_SETICONSPACING, 0, BitOR(BitShift($i_cy, -16), BitAND($i_cx, 0xFFFF)))
  1897.     Else
  1898. ;~         Return GUICtrlSendMsg($h_listview, $LVM_SETICONSPACING, 0, $i_cx * 65536 + $i_cy)
  1899.         Return GUICtrlSendMsg($h_listview, $LVM_SETICONSPACING, 0, BitOR(BitShift($i_cy, -16), BitAND($i_cx, 0xFFFF)))
  1900.     EndIf
  1901. EndFunc   ;==>_GUICtrlListViewSetIconSpacing
  1902.  
  1903. ;===============================================================================
  1904. ; ====================================================================================================
  1905. ; Description ..: Moves an item to a specified position in a listview control.  The control must be in
  1906. ;                 icon or small icon view.
  1907. ; Parameters ...: $h_listview        - Handle to control
  1908. ;                 $i_index       - Zero based index of the item
  1909. ;                 $i_x          - New x-position of the item's upper-left corner, in view coordinates
  1910. ;                 $i_y          - New y-position of the item's upper-left corner, in view coordinates
  1911. ; Return values : Success - True
  1912. ;                 Failure - False
  1913. ; Notes ........: If the listview control has the $LVS_AUTOARRANGE style, the  items  in  the  listview
  1914. ;                 control are arranged after the position of the item is set.
  1915. ; ====================================================================================================
  1916. Func _GUICtrlListViewSetItemPosition($h_listview, $i_index, $i_x, $i_y)
  1917.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, False)
  1918.     If IsHWnd($h_listview) Then
  1919. ;~         Return _SendMessage ($h_listview, $LVM_SETITEMPOSITION, $i_index, $i_x * 65536 + $i_y)
  1920.         Return _SendMessage($h_listview, $LVM_SETITEMPOSITION, $i_index, BitOR(BitShift($i_y, -16), BitAND($i_x, 0xFFFF)))
  1921.     Else
  1922. ;~         Return GUICtrlSendMsg($h_listview, $LVM_SETITEMPOSITION, $i_index, $i_x * 65536 + $i_y)
  1923.         Return GUICtrlSendMsg($h_listview, $LVM_SETITEMPOSITION, $i_index, BitOR(BitShift($i_y, -16), BitAND($i_x, 0xFFFF)))
  1924.     EndIf
  1925. EndFunc   ;==>_GUICtrlListViewSetItemPosition
  1926.  
  1927. ; ====================================================================================================
  1928. ; Description ..: Sets the view of a listview control
  1929. ; Parameters ...: $h_listview        - Handle to control
  1930. ;                 $i_View        - View state for the control:
  1931. ;                   $LV_VIEW_DETAILS
  1932. ;                   $LV_VIEW_ICON
  1933. ;                   $LV_VIEW_LIST
  1934. ;                   $LV_VIEW_SMALLICON
  1935. ;                   $LV_VIEW_TILE
  1936. ; Return values : Only available for Windows XP
  1937. ; ====================================================================================================
  1938. Func _GUICtrlListViewSetView($h_listview, $i_View)
  1939.     If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, 0)
  1940.     If $i_View <> $LV_VIEW_DETAILS And $i_View <> $LV_VIEW_ICON And $i_View <> $LV_VIEW_LIST And _
  1941.             $i_View <> $LV_VIEW_SMALLICON And $i_View <> $LV_VIEW_TILE Then Return SetError($LV_ERR, $LV_ERR, 0)
  1942.  
  1943.     If IsHWnd($h_listview) Then
  1944.         Return _SendMessage($h_listview, $LVM_SETVIEW, $i_View)
  1945.     Else
  1946.         Return GUICtrlSendMsg($h_listview, $LVM_SETVIEW, $i_View, 0)
  1947.     EndIf
  1948. EndFunc   ;==>_GUICtrlListViewSetView